Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --teleport to coin v.01 testing on vps2
- --fix Random Target Coin
- if not game:IsLoaded() then
- game.Loaded:Wait()
- end
- task.wait(10)
- -- Disable collision for all BaseParts in the character
- task.spawn(function()
- task.wait(10)
- while true do
- pcall(function()
- for _, v in pairs(game.Players.LocalPlayer.Character:GetDescendants()) do
- if v:IsA("BasePart") and v.CanCollide == true then
- v.CanCollide = false
- end
- end
- end)
- game:GetService("RunService").Stepped:Wait()
- end
- end)
- task.spawn(function()
- task.wait(30)
- firesignal(game:GetService("Players").LocalPlayer.PlayerGui.MainGUI.Game.Leaderboard.Container.Close.Toggle.MouseButton1Click)
- end)
- task.spawn(function()
- task.wait(30)
- -- Create GUI elements
- local coreGui = game:GetService("CoreGui")
- -- Check if GUI already exists (to avoid duplicates)
- local existingGui = coreGui:FindFirstChild("CountdownGui")
- if existingGui then
- existingGui:Destroy()
- end
- local screenGui = Instance.new("ScreenGui")
- screenGui.Name = "CountdownGui"
- screenGui.Parent = coreGui
- local timerLabel = Instance.new("TextLabel", screenGui)
- timerLabel.Name = "TimerLabel"
- timerLabel.Size = UDim2.new(0.2, 0, 0.15, 0) -- Adjust size
- timerLabel.Position = UDim2.new(0.4, 0, -0.05, 0) -- Adjust position
- timerLabel.BackgroundColor3 = Color3.new(0, 0, 0) -- Black background
- timerLabel.TextColor3 = Color3.new(1, 1, 1) -- White text
- timerLabel.TextScaled = true
- timerLabel.Font = Enum.Font.SourceSansBold
- timerLabel.Text = "Waiting..."
- -- Timer connection
- local timerPart = game:GetService("Workspace"):FindFirstChild("RoundTimerPart")
- if timerPart and timerPart:FindFirstChild("SurfaceGui") and timerPart.SurfaceGui:FindFirstChild("Timer") then
- local timerText = timerPart.SurfaceGui.Timer
- timerText:GetPropertyChangedSignal("Text"):Connect(function()
- timerLabel.Text = timerText.Text
- end)
- else
- timerLabel.Text = "Timer not found"
- end
- end)
- local player = game.Players.LocalPlayer
- local character = player.Character or player.CharacterAdded:Wait()
- local humanoidRootPart = character:WaitForChild("HumanoidRootPart")
- -- Function to create a platform under the player's feet with adjustable size
- local function createPlatform()
- -- Check if platform already exists
- local existingPlatform = workspace:FindFirstChild("Papan")
- if existingPlatform then
- return existingPlatform
- end
- -- Create a new part (the platform)
- local platform = Instance.new("Part")
- platform.Size = Vector3.new(5, 0.2, 5) -- Bigger platform with smaller height
- platform.Anchored = true
- platform.CanCollide = true
- platform.Material = Enum.Material.SmoothPlastic
- platform.Color = Color3.new(1, 1, 1) -- White platform
- platform.Name = "Papan" -- Renamed to "Papan"
- -- Set the platform's position to the custom CFrame
- local randomX = math.random(-100, -50) -- Adjust range as needed
- local randomZ = math.random(-150, -100) -- Adjust range as needed
- platform.CFrame = CFrame.new(randomX, -180, randomZ)
- -- Parent the platform to the workspace
- platform.Parent = workspace
- return platform
- end
- -- Ensure the platform is always created and in position
- task.spawn(function()
- while true do
- createPlatform()
- task.wait(1) -- Check every second to ensure the platform is present
- end
- end)
- -- Function to teleport player on top of the platform
- local function teleportToPlatform()
- local platform = workspace:FindFirstChild("Papan")
- if not platform then
- platform = createPlatform()
- end
- if humanoidRootPart then
- -- Adjust Y offset to place the player above the platform
- local yOffset = platform.Size.Y / 2 + humanoidRootPart.Size.Y / 2 + 4 -- 4 is the additional height above the platform
- humanoidRootPart.CFrame = platform.CFrame + Vector3.new(0, yOffset, 0)
- end
- end
- -- Function to tween the player using BodyVelocity and CFrame
- local function tweenWithBodyVelocity(targetCFrame)
- local bodyVelocity = humanoidRootPart:FindFirstChild("BodyVelocity")
- if not bodyVelocity then
- bodyVelocity = Instance.new("BodyVelocity")
- bodyVelocity.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
- bodyVelocity.P = 1250
- bodyVelocity.Velocity = Vector3.zero
- bodyVelocity.Parent = humanoidRootPart
- end
- local duration = 0.2 -- Tween duration
- local startTime = tick()
- local startCFrame = humanoidRootPart.CFrame
- local elapsedTime = 0
- while elapsedTime < duration do
- elapsedTime = tick() - startTime
- local alpha = elapsedTime / duration
- local currentCFrame = startCFrame:Lerp(targetCFrame, alpha)
- local velocity = (currentCFrame.Position - humanoidRootPart.Position).Unit * 25 -- Adjust speed
- bodyVelocity.Velocity = velocity
- humanoidRootPart.CFrame = currentCFrame
- task.wait(0.01)
- end
- -- Stop movement
- bodyVelocity.Velocity = Vector3.zero
- bodyVelocity:Destroy()
- -- Snap to the final target position
- humanoidRootPart.CFrame = targetCFrame
- end
- local function resetAutofarm()
- isCollectingCoin = false
- if AutofarmIN and AutofarmStarted and not RoundEnded then
- teleportToPlatform()
- end
- end
- local isCollectingCoin = false
- local RoundEnded = false
- player.CharacterAdded:Connect(function(newCharacter)
- character = newCharacter
- humanoidRootPart = newCharacter:WaitForChild("HumanoidRootPart")
- resetAutofarm()
- end)
- SettingsAutofarm = _G.AutofarmSettings or {AntiAfk = true, ResetWhenFullBag = true}
- _G.AutofarmSettings = SettingsAutofarm
- if _G.AutoFarmMM2IsLoaded then return end
- _G.AutoFarmMM2IsLoaded = true
- local Player = game.Players.LocalPlayer
- local Players = game.Players
- local RunService = game:GetService("RunService")
- local TweenService = game:GetService("TweenService")
- local CoinCollectedEvent = game.ReplicatedStorage.Remotes.Gameplay.CoinCollected
- local RoundStartEvent = game.ReplicatedStorage.Remotes.Gameplay.RoundStart
- local RoundEndEvent = game.ReplicatedStorage.Remotes.Gameplay.RoundEndFade
- local autofarmstopevent = Instance.new("BindableEvent")
- local function AntiAFK()
- local GC = getconnections or get_signal_cons
- if GC then
- for _, v in pairs(GC(Player.Idled)) do
- if v["Disable"] then
- v["Disable"](v)
- elseif v["Disconnect"] then
- v["Disconnect"](v)
- end
- end
- else
- local VirtualUser = cloneref(game:GetService("VirtualUser"))
- Players.LocalPlayer.Idled:Connect(function()
- VirtualUser:CaptureController()
- VirtualUser:ClickButton2(Vector2.new())
- end)
- end
- end
- local ResetWhenFullBag = SettingsAutofarm.ResetWhenFullBag
- local AutofarmIN = false
- local AutofarmStarted = true
- local CurrentCoinType = "SnowToken"
- local function returncoincontainer()
- for _, v in workspace:GetChildren() do
- if v:FindFirstChild("CoinContainer") and v:IsA("Model") then
- return v:FindFirstChild("CoinContainer")
- end
- end
- return false
- end
- local function getRandomCoin(container)
- local coins = container:GetChildren()
- -- Shuffle the coins to randomize selection
- for i = #coins, 2, -1 do
- local j = math.random(1, i)
- coins[i], coins[j] = coins[j], coins[i]
- end
- for _, coin in ipairs(coins) do
- if coin:FindFirstChild("TouchInterest") then
- return coin
- end
- end
- return nil
- end
- local function StayOnPlatform()
- if not isCollectingCoin then
- teleportToPlatform()
- task.wait(0.7 + math.random() * 0.1)
- end
- end
- task.spawn(function()
- while true do
- if AutofarmStarted and AutofarmIN and Player.Character and returncoincontainer() then
- -- Step 1: Stay on the platform
- StayOnPlatform()
- -- Step 2: Move to random coin with TouchInterest
- local coinContainer = returncoincontainer()
- if coinContainer then
- isCollectingCoin = true
- local coin = getRandomCoin(coinContainer)
- if coin then
- -- Tween to target position using BodyVelocity and CFrame
- tweenWithBodyVelocity(coin.CFrame)
- -- Fire touch interest to collect the coin
- pcall(function()
- firetouchinterest(Player.Character.HumanoidRootPart, coin, 0)
- task.wait(0.01)
- end)
- -- Wait until the coin is collected or gone
- while coin.Parent == coinContainer and coin:FindFirstChild("TouchInterest") do
- task.wait(0.1)
- end
- -- Wait before returning to platform
- task.wait(0.2 + math.random() * 0.4)
- end
- -- Step 3: Return to platform
- isCollectingCoin = false
- if AutofarmIN and AutofarmStarted and not RoundEnded then
- StayOnPlatform()
- end
- end
- else
- task.wait(0.1)
- end
- task.wait(0.05)
- end
- end)
- CoinCollectedEvent.OnClientEvent:Connect(function(cointype, current, max)
- AutofarmIN = true
- if cointype == CurrentCoinType and tonumber(current) == tonumber(max) then
- AutofarmIN = false
- if ResetWhenFullBag then
- Player.Character.Humanoid.Health = 0
- end
- end
- end)
- RoundStartEvent.OnClientEvent:Connect(function()
- AutofarmIN = true
- RoundEnded = false
- resetAutofarm()
- -- Update timer on round start
- local timerPart = game:GetService("Workspace"):FindFirstChild("RoundTimerPart")
- local screenGui = game:GetService("CoreGui"):FindFirstChild("CountdownGui")
- if not screenGui then
- screenGui = Instance.new("ScreenGui")
- screenGui.Name = "CountdownGui"
- screenGui.Parent = game:GetService("CoreGui")
- local timerLabel = Instance.new("TextLabel", screenGui)
- timerLabel.Name = "TimerLabel"
- timerLabel.Size = UDim2.new(0.2, 0, 0.15, 0)
- timerLabel.Position = UDim2.new(0.4, 0, -0.05, 0)
- timerLabel.BackgroundColor3 = Color3.new(0, 0, 0)
- timerLabel.TextColor3 = Color3.new(1, 1, 1)
- timerLabel.TextScaled = true
- timerLabel.Font = Enum.Font.SourceSansBold
- timerLabel.Text = "Waiting..."
- end
- local timerLabel = screenGui:FindFirstChild("TimerLabel")
- if timerPart and timerPart:FindFirstChild("SurfaceGui") and timerPart.SurfaceGui:FindFirstChild("Timer") then
- local timerText = timerPart.SurfaceGui.Timer
- timerText:GetPropertyChangedSignal("Text"):Connect(function()
- if timerLabel then
- timerLabel.Text = timerText.Text
- end
- end)
- -- Initialize label with the current timer value
- if timerLabel then
- timerLabel.Text = timerText.Text
- end
- else
- if timerLabel then
- timerLabel.Text = "Timer not found"
- end
- end
- end)
- RoundEndEvent.OnClientEvent:Connect(function()
- AutofarmIN = false
- RoundEnded = true
- task.wait(1)
- end)
- RunService.Heartbeat:Connect(function()
- if AutofarmIN then
- StayOnPlatform()
- end
- end)
- AntiAFK()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement