Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- MM2 AutoFarm (TWEEN) --
- if _G.MurderMystery2AutoFarmScriptNoGui then return end
- pcall(function() _G.MurderMystery2AutoFarmScriptNoGui = true end)
- if not game:IsLoaded() then
- game.Loaded:Wait()
- end
- local PlaceId, JobId = 142823291, game.JobId
- -- References --
- local cloneref = cloneref or function(o) return o end
- local Players = cloneref(game:GetService("Players"))
- local LocalPlayer = Players.LocalPlayer
- local GuiService = cloneref(game:GetService("GuiService"))
- local PlayerScripts = LocalPlayer:FindFirstChildOfClass("PlayerScripts")
- local VirtualUser = cloneref(game:GetService("VirtualUser"))
- local Workspace = cloneref(game:GetService("Workspace"))
- local CollectionService = cloneref(game:GetService("CollectionService"))
- local ReplicatedStorage = cloneref(game:GetService("ReplicatedStorage"))
- local RunService = cloneref(game:GetService("RunService"))
- local TeleportService = cloneref(game:GetService("TeleportService"))
- local QueueTeleport = queue_on_teleport or (syn and syn.queue_on_teleport) or (fluxus and fluxus.queue_on_teleport)
- local HttpRequest = (syn and syn.request) or (http and http.request) or http_request or (fluxus and fluxus.request) or request
- local HttpService = cloneref(game:GetService("HttpService"))
- local TweenService = cloneref(game:GetService("TweenService"))
- if not QueueTeleport then warn("❌ [Incompatible Exploit] : Your exploit does not support queue_on_teleport") end
- -- Data(s) --
- local LocalPlayerData = {CollectedCoins = {}, CanShoot = true, DontDisturb = false, Died = false, ResetAttempt = false, JoinAttempt = false, WaitTime = 0, TimePassed = 0}
- local Map = {CurrentMap, CurrentGun}
- -- Character Position Handler --
- local PartHolder = Instance.new("Folder", Workspace)
- local FloatPart = Instance.new("Part", PartHolder)
- FloatPart.Size = Vector3.one
- FloatPart.Anchored = true
- FloatPart.Position = Vector3.zero
- FloatPart.Massless = true
- FloatPart.CanCollide = false
- FloatPart.CastShadow = false
- FloatPart.CFrame *= CFrame.Angles(math.rad(90), 0, 0)
- -- Functions --
- local function RandomStrings()
- local Length, Array = math.random(10,20), {}
- for i = 1, Length do
- Array[i] = string.char(math.random(32, 126))
- end
- return table.concat(Array)
- end
- local function ReJoin()
- task.spawn(function()
- if LocalPlayerData.JoinAttempt then return end
- if not QueueTeleport then return warn("❌ [Incompatible Exploit] : Your exploit does not support queue_on_teleport") end
- LocalPlayerData.JoinAttempt = true
- while task.wait(1) do
- warn("ReJoining!")
- task.spawn(function()
- local Servers = {}
- pcall(function()
- local Request = HttpRequest and HttpRequest({Url = string.format("https://games.roblox.com/v1/games/%d/servers/Public?sortOrder=Desc&limit=100&excludeFullGames=true", PlaceId)})
- local Body = Request and HttpService:JSONDecode(Request.Body)
- if Body and Body.data then
- for i, v in next, Body.data do
- if type(v) == "table" and tonumber(v.playing) and tonumber(v.maxPlayers) and v.playing < v.maxPlayers and v.id ~= JobId then
- table.insert(Servers, 1, v.id)
- end
- end
- end
- QueueTeleport("loadstring(game:HttpGet('https://pastebin.com/raw/YLVX19kg'))()")
- end)
- task.wait(.5)
- _G.MurderMystery2AutoFarmScriptNoGui = false
- LocalPlayer:Kick("\nJoining MM2 ...")
- if #Servers > 0 then
- TeleportService:TeleportToPlaceInstance(PlaceId, Servers[math.random(1, #Servers)], LocalPlayer)
- else
- TeleportService:Teleport(PlaceId, LocalPlayer)
- end
- end)
- end
- end)
- end
- -- LocalPlayer Functions --
- local function SecondLife(Boolean)
- local LocalHumanoid = LocalPlayer.Character and LocalPlayer.Character:FindFirstChildOfClass("Humanoid")
- if LocalHumanoid then LocalHumanoid:SetStateEnabled(Enum.HumanoidStateType.Dead, not Boolean) end
- end
- local function ResetCharacter()
- local LocalHumanoid = LocalPlayer.Character and LocalPlayer.Character:FindFirstChildOfClass("Humanoid")
- local LocalHead = LocalHumanoid and LocalHumanoid.Parent:FindFirstChild("Head")
- if LocalHumanoid and LocalHead then
- LocalPlayerData.ResetAttempt = true
- task.wait(.1)
- SecondLife(false)
- LocalHumanoid.Health = -math.huge
- LocalHead:Destroy()
- SecondLife(false)
- LocalHumanoid:ChangeState(Enum.HumanoidStateType.Dead)
- task.wait(.1)
- LocalPlayerData.ResetAttempt = false
- end
- end
- -- Checks --
- if tostring(game.PlaceId) ~= tostring(PlaceId) then
- return ReJoin()
- end
- -- Roles --
- local Roles = {RoleTable = {}, Murderers = {}, Sheriffs = {}, GameMode, RoundEnded = false}
- function Roles:IsAlive(Player)
- for Name, Data in pairs(self.RoleTable or {}) do
- if Player.Name == Name then return not Data.Dead end
- end
- return false
- end
- function Roles:FindWeapon(WeaponName, Player, GetInstance)
- local FinalResult = nil
- pcall(function()
- if not (WeaponName and Player) then return end
- local function CheckWeapon(Weapon, IsLocal)
- if not (Weapon and Weapon:IsA("Tool")) then return end
- if Weapon.Name == "Gun" then
- local Handle, IsGun, KnifeServer, KnifeLocal = Weapon:FindFirstChild("Handle"), Weapon:FindFirstChild("IsGun"), Weapon:FindFirstChild("KnifeServer"), Weapon:FindFirstChild("KnifeLocal")
- if not (Handle and IsGun and KnifeServer and KnifeLocal) then return end
- local ShootGun = IsLocal and KnifeLocal:FindFirstChild("CreateBeam") and KnifeLocal.CreateBeam.RemoteFunction or KnifeServer:FindFirstChild("ShootGun")
- return ShootGun and (GetInstance and {KnifeServer = KnifeServer, KnifeLocal = KnifeLocal, ShootGun = ShootGun, Handle = Handle} or true)
- elseif Weapon.Name == "Knife" then
- local Handle, KnifeServer, Stab, Throw = Weapon:FindFirstChild("Handle"), Weapon:FindFirstChild("KnifeServer"), Weapon:FindFirstChild("Stab"), Weapon:FindFirstChild("Throw")
- if not (Handle and KnifeServer and Stab and Throw) then return end
- return GetInstance and {KnifeServer = KnifeServer, Stab = Stab, Throw = Throw, Handle = Handle} or true
- end
- end
- local Parents = {Player.Character, Player:FindFirstChildOfClass("Backpack")}
- for _, Parent in pairs(Parents) do
- if Parent then
- local Weapon = Parent:FindFirstChild(WeaponName)
- local Result = Weapon and CheckWeapon(Weapon, Player == LocalPlayer)
- if Result then FinalResult = Result end
- end
- end
- end)
- return FinalResult
- end
- function Roles:UpdateRole()
- local GetPlayerData = ReplicatedStorage:FindFirstChild("Remotes") and ReplicatedStorage.Remotes:FindFirstChild("Extras") and ReplicatedStorage.Remotes.Extras:FindFirstChild("GetPlayerData", true)
- if not GetPlayerData then return end
- pcall(function()
- self.RoleTable, self.CanGetRoles = GetPlayerData:InvokeServer(), true
- end)
- for Name, Data in pairs(self.RoleTable or Players:GetPlayers()) do
- local ThePlayer = self.RoleTable and Players:FindFirstChild(Name) or (not self.RoleTable and Data)
- if ThePlayer then
- if (self.RoleTable and Data.Role == "Murderer" and self:IsAlive(ThePlayer)) or self:FindWeapon("Knife", ThePlayer, false) then
- if not table.find(self.Murderers, ThePlayer.Name) then table.insert(self.Murderers, ThePlayer.Name) end
- elseif (self.RoleTable and Data.Role == "Sheriff" and self:IsAlive(ThePlayer)) or self:FindWeapon("Gun", ThePlayer, false) then
- if not table.find(self.Sheriffs, ThePlayer.Name) then table.insert(self.Sheriffs, ThePlayer.Name) end
- else
- for Role, Player in pairs(self) do
- if tostring(Role) == "Sheriffs" or tostring(Role) == "Murderers" then
- local Finded = table.find(self[tostring(Role)], ThePlayer.Name)
- if Finded then table.remove(self[tostring(Role)], Finded) end
- end
- end
- end
- end
- end
- end
- local AutoFarm = {Status = {Complete = false, Ready = true}, CurrentTween, CurrentCoin, FlingOffset = {XZ = math.random(-10, 10), Y = math.random(-10, 10)}}
- function AutoFarm:GetClosestCoin()
- local Result, ClosestDistance = nil, math.huge
- local LocalRoot = LocalPlayer.Character and LocalPlayer.Character.PrimaryPart
- if not LocalRoot then return end
- for _, CoinVisual in pairs(CollectionService:GetTagged("CoinVisual")) do
- local Parent = CoinVisual.Parent
- if Parent and Parent:FindFirstChildOfClass("TouchTransmitter") and not Parent:GetAttribute("Collected") and not Parent:GetAttribute("RoundEnd") then
- local Distance = (LocalRoot.Position - Parent.Position).Magnitude
- if Distance < ClosestDistance then Result, ClosestDistance = Parent, Distance end
- end
- end
- return Result
- end
- -- MAIN :
- PartHolder.Name, FloatPart.Name = RandomStrings(), RandomStrings()
- RunService.RenderStepped:Connect(function()
- local LocalHumanoid = LocalPlayer.Character and LocalPlayer.Character:FindFirstChildOfClass("Humanoid")
- local LocalRoot = LocalHumanoid and LocalHumanoid.RootPart
- LocalPlayerData.Died = not Roles:IsAlive(LocalPlayer)
- if LocalHumanoid and LocalRoot then
- if Map.CurrentMap and not AutoFarm.Status.Complete and not LocalPlayerData.Died then
- LocalPlayerData.DontDisturb = false
- local ClosestCoin = AutoFarm:GetClosestCoin()
- if ClosestCoin then
- local GoalPosition = ClosestCoin.Position + Vector3.new(0, -5, 0)
- local Distance = (LocalRoot.Position - ClosestCoin.Position).Magnitude
- if not AutoFarm.CurrentTween and AutoFarm.Status.Ready then
- local TweenResult = TweenService:Create(FloatPart, TweenInfo.new(Distance * .04, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut), {Position = GoalPosition})
- AutoFarm.CurrentTween, AutoFarm.CurrentCoin = TweenResult, ClosestCoin
- AutoFarm.CurrentTween.Completed:Connect(function()
- if (LocalRoot.Position - AutoFarm.CurrentCoin.Position).Magnitude < 10 then
- ClosestCoin.Size = Vector3.new(5, 5, 5)
- task.wait(.05)
- ClosestCoin.Size = Vector3.new(10, 10, 10)
- task.wait(math.random(5, 6) / 10)
- ClosestCoin:SetAttribute("Collected", true)
- end
- AutoFarm.CurrentTween, AutoFarm.Status.Ready = nil, true
- end)
- AutoFarm.Status.Ready = false
- AutoFarm.CurrentTween:Play()
- elseif AutoFarm.CurrentCoin ~= ClosestCoin and AutoFarm.CurrentTween then
- AutoFarm.CurrentCoin = ClosestCoin
- AutoFarm.CurrentTween:Cancel()
- elseif Distance > 300 or Distance < 10 then
- if AutoFarm.CurrentTween then
- AutoFarm.CurrentTween:Cancel()
- end
- FloatPart.Position = GoalPosition
- end
- end
- elseif AutoFarm.Status.Complete or LocalPlayerData.Died then
- local Knife, Gun = Roles:FindWeapon("Knife", LocalPlayer, true), Roles:FindWeapon("Gun", LocalPlayer, true)
- if Knife then
- for _, Player in pairs(Players:GetPlayers()) do
- if Player ~= LocalPlayer and Roles.GameMode ~= "Classic" then
- LocalHumanoid:EquipTool(Knife.Handle.Parent)
- local Handle, Stab, OtherRoot = Knife.Handle, Knife.Stab, Player.Character and Player.Character.PrimaryPart
- if Handle and Stab and OtherRoot and Roles:IsAlive(Player) then
- Handle.Size, Handle.Massless, OtherRoot.CanCollide, OtherRoot.Size, OtherRoot.Massless, OtherRoot.Anchored, OtherRoot.Position = Vector3.new(10, 10, 10), true, false, Vector3.new(5, 5, 5), true, true, Handle.Position
- task.spawn(function() pcall(function() Stab:FireServer("Stab") end) end)
- end
- end
- end
- elseif not Roles.RoundEnded then
- local Murderer = (#Roles.Murderers > 0) and Players:FindFirstChild(Roles.Murderers[1])
- if Murderer and Murderer ~= LocalPlayer then
- LocalPlayerData.DontDisturb = true
- local MurdererRoot = Murderer.Character and Murderer.Character.PrimaryPart
- if MurdererRoot and MurdererRoot.AssemblyLinearVelocity.Magnitude < 250 and MurdererRoot.Position.Y > Workspace.FallenPartsDestroyHeight + 100 then
- Workspace.CurrentCamera.CameraSubject = MurdererRoot.Parent
- local MurdererVelocity = MurdererRoot.AssemblyLinearVelocity
- local Prediction = (MurdererRoot.Position + ( MurdererVelocity * Vector3.new(1, 0, 1) * ((AutoFarm.FlingOffset.XZ + (AutoFarm.FlingOffset.XZ == 0 and 1 or 0)) / 10) + Vector3.new(0, MurdererVelocity.Y / (AutoFarm.FlingOffset.Y + (AutoFarm.FlingOffset.Y == 0 and 1 or 0)), 0)))
- FloatPart.Position = Prediction
- if Gun then
- if Gun.Handle.Parent.Parent ~= LocalHumanoid.Parent then
- LocalHumanoid:EquipTool(Gun.Handle.Parent)
- end
- local PredictedPosition = MurdererRoot.Position + ( MurdererVelocity * Vector3.new(1, 0, 1) * (math.random(20, 28) / 100) + Vector3.new(0, MurdererVelocity.Y * (math.random(20, 60) / 1000), 0) )
- task.spawn(function()
- if LocalPlayerData.CanShoot then
- LocalPlayerData.CanShoot = false
- pcall(function()
- Gun.ShootGun:InvokeServer(unpack({[1] = 1, [2] = PredictedPosition, [3] = "AH2"}))
- end)
- LocalPlayerData.CanShoot = true
- end
- end)
- end
- else
- LocalPlayerData.DontDisturb = false
- end
- else
- LocalPlayerData.DontDisturb = false
- end
- end
- end
- if Map.CurrentGun then Map.CurrentGun.Position = LocalRoot.Position end
- if AutoFarm.Status.Complete and not LocalPlayerData.DontDisturb or Roles.RoundEnded then FloatPart.Position = Vector3.zero end
- LocalRoot.CFrame = FloatPart.CFrame
- if not LocalPlayerData.DontDisturb then Workspace.CurrentCamera.CameraSubject = FloatPart end
- for _, Child in pairs(LocalHumanoid.Parent:GetDescendants()) do
- if Child:IsA("BasePart") then Child.CanCollide = false end
- end
- end
- end)
- RunService.Heartbeat:Connect(function()
- local LocalRoot = LocalPlayer.Character and LocalPlayer.Character.PrimaryPart
- if LocalRoot then
- LocalRoot.AssemblyLinearVelocity = Vector3.new(0, LocalPlayerData.DontDisturb and -100e3 or 0, 0)
- RunService.RenderStepped:Wait()
- LocalRoot.AssemblyLinearVelocity = Vector3.zero
- end
- end)
- task.spawn(function()
- while task.wait(.15) do
- AutoFarm.FlingOffset.XZ, AutoFarm.FlingOffset.Y = math.random(-10, 10), math.random(-10, 10)
- end
- end)
- task.spawn(function()
- while task.wait(1) do
- task.spawn(function() Roles:UpdateRole() end)
- if not LocalPlayerData.ResetAttempt then SecondLife(true) end
- local function ShootGun(Player, Args)
- local IsBreakGun = (Args and Args[2] == Vector2.new())
- if not (Player and Args) then return end
- local Gun = Roles:FindWeapon("Gun", Player, true)
- local ShootGun = Gun and (not IsBreakGun and Gun.Handle.Parent.Parent:IsA("Model") or IsBreakGun and true) and Gun.ShootGun
- if not ShootGun then return end
- task.spawn(function() pcall(function() ShootGun:InvokeServer(unpack(Args)) end) end)
- end
- for _, Player in pairs(Players:GetPlayers()) do
- if Player ~= LocalPlayer then
- if Roles:FindWeapon("Gun", Player, false) then ShootGun(Player, {[1] = 1, [2] = Vector2.new(), [3] = "AH2"}) end
- end
- end
- if not Map.CurrentMap then
- local function GetMap()
- for _, Child in pairs(Workspace:GetChildren()) do
- local Spawns, CoinContainer = Child:FindFirstChild("Spawns"), Child:FindFirstChild("CoinAreas") or Child:FindFirstChild("CoinContainer")
- if Child:IsA("Model") and not Players:GetPlayerFromCharacter(Child) and Spawns and CoinContainer then return {Map = Child, Spawns = Spawns, CoinContainer = CoinContainer} end
- end
- return
- end
- local CurrentMap = GetMap()
- if CurrentMap then
- Map.CurrentMap = CurrentMap
- local function CheckGun(Child)
- if Child:IsA("BasePart") and Child.Name == "GunDrop" then
- Map.CurrentGun = Child
- Child.Size = Vector3.new(10, 10, 10)
- local GunConnection
- GunConnection = Child.Changed:Connect(function()
- if not Child.Parent then
- Map.CurrentGun = nil
- GunConnection:Disconnect()
- end
- end)
- end
- end
- for _, Child in pairs(CurrentMap.Map:GetChildren()) do
- CheckGun(Child)
- end
- CurrentMap.Map.ChildAdded:Connect(CheckGun)
- local Connection
- Connection = CurrentMap.Map.Changed:Connect(function()
- if not CurrentMap.Map.Parent then
- Map.CurrentMap, AutoFarm.Status.Complete, Roles.RoundEnded, LocalPlayerData.DontDisturb, LocalPlayerData.CollectedCoins = nil, true, true, false, {}
- Connection:Disconnect()
- end
- end)
- end
- end
- local Objects = {"CoinVisual", "ChromaDecal", "ChromaFire", "ChromaPart"}
- for _, Object in pairs(Objects) do
- for _, Instance in pairs(CollectionService:GetTagged(Object)) do
- if Object:lower():find("chroma") then
- Instance:Destroy()
- elseif Object == "CoinVisual" then
- local Parent = Instance.Parent
- if Parent then
- if Instance:GetAttribute("Collected") or Instance:GetAttribute("RoundEnd") or (table.find(LocalPlayerData.CollectedCoins, Instance:GetAttribute("CoinID")) and LocalPlayerData.CollectedCoins[Instance:GetAttribute("CoinID")].IsFull) then
- if Instance:GetAttribute("RoundEnd") then
- AutoFarm.Status.Complete, Roles.RoundEnded = true, true
- end
- Parent:Destroy()
- else
- Parent.Size = Vector3.new(10, 10, 10)
- end
- end
- end
- end
- end
- LocalPlayerData.WaitTime += 1
- LocalPlayerData.TimePassed += 1
- if #Players:GetPlayers() < 3 or LocalPlayerData.WaitTime > 180 or LocalPlayerData.TimePassed > 1200 then
- ReJoin()
- end
- end
- end)
- task.spawn(function()
- for _, Player in pairs(Players:GetPlayers()) do
- for _, WeaponName in pairs({"Gun", "Knife"}) do
- local Weapon = Roles:FindWeapon(WeaponName, Player, true)
- if Weapon and Weapon.KnifeServer then
- local GameMode = Weapon.KnifeServer:FindFirstChild("GameMode")
- if GameMode and GameMode:IsA("StringValue") then
- Roles.GameMode = tostring(GameMode.Value)
- break
- end
- end
- end
- end
- local Folders = {"Footsteps", "WeaponDisplays", "PetContainer"}
- for _, Folder in pairs(Workspace:GetChildren()) do
- if table.find(Folders, Folder.Name) and Folder:IsA("Folder") then
- Folder:Destroy()
- end
- end
- Workspace.ChildAdded:Connect(function(Child)
- if Child.Name == "Footsteps" and Child:IsA("Folder") then
- task.wait()
- Child:Destroy()
- end
- end)
- local Scripts = {"Pets", "CoinVisualizer", PlayerScripts:FindFirstChild("WeaponVisuals") and PlayerScripts.WeaponVisuals:FindFirstChild("ChromaScript")}
- for _, Script in pairs(Scripts) do
- local LocalScript = PlayerScripts and (tostring(Script) and PlayerScripts:FindFirstChild(Script) or Script)
- if LocalScript then LocalScript:Destroy() end
- end
- local RemotesName = {"CoinsStarted", "CoinCollected", "LoadingMap"}
- local GamePlay = ReplicatedStorage:WaitForChild("Remotes") and ReplicatedStorage.Remotes:WaitForChild("Gameplay")
- if GamePlay then
- for _, Name in pairs(RemotesName) do
- local Remote = GamePlay:WaitForChild(Name)
- if Remote then
- if Name == "CoinsStarted" then
- Remote.OnClientEvent:Connect(function()
- AutoFarm.Status.Complete, Roles.RoundEnded, LocalPlayerData.DontDisturb, LocalPlayerData.CollectedCoins, LocalPlayerData.WaitTime = false, false, false, {}, 0
- end)
- elseif Name == "CoinCollected" then
- Remote.OnClientEvent:Connect(function(...)
- local Args = {...}
- local CoinType, CoinCollected, CoinBagLimit = Args[1], Args[2], Args[3]
- if not table.find(LocalPlayerData.CollectedCoins, CoinType) then table.insert(LocalPlayerData.CollectedCoins, CoinType) end
- LocalPlayerData.CollectedCoins[CoinType], LocalPlayerData.WaitTime = {IsFull = false, Limit = CoinBagLimit}, 0
- if CoinBagLimit == CoinCollected then
- LocalPlayerData.CollectedCoins[CoinType] = {IsFull = true, Limit = CoinBagLimit}
- for _, CoinVisual in pairs(CollectionService:GetTagged("CoinVisual")) do
- if CoinVisual:GetAttribute("CoinID") == CoinType and CoinVisual.Parent then
- CoinVisual.Parent:Destroy()
- end
- end
- local Completed = 0
- for _, CoinTypes in pairs(LocalPlayerData.CollectedCoins) do
- if CoinTypes.IsFull then Completed = Completed + 1 end
- end
- if Completed > 0 and #LocalPlayerData.CollectedCoins == Completed then
- AutoFarm.Status.Complete = true
- if table.find(Roles.Murderers, LocalPlayer.Name) and Roles.GameMode == "Classic" then ResetCharacter() end
- end
- end
- end)
- elseif Name == "LoadingMap" then
- Remote.OnClientEvent:Connect(function(...)
- local Args = {...}
- Roles.GameMode, AutoFarm.Status.Complete, LocalPlayerData.DontDisturb, LocalPlayerData.WaitTime = Args[1], false, false, 0
- end)
- end
- end
- end
- end
- LocalPlayer.Idled:Connect(function()
- VirtualUser:CaptureController()
- VirtualUser:ClickButton2(Vector2.zero)
- end)
- GuiService.ErrorMessageChanged:Connect(ReJoin)
- end)
- local LastCharacter = LocalPlayer.Character
- LocalPlayer.CharacterAdded:Connect(function(Character)
- if Character ~= LastCharacter and Character and Players:GetPlayerFromCharacter(Character) then
- LastCharacter = Character
- Roles.Sheriffs, Roles.Murderers, Roles.RoleTable = {}, {}, nil
- FloatPart.Position, LocalPlayerData.DontDisturb, LocalPlayerData.CanShoot = Vector3.zero, false, true
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement