Coin Farm

public
vxpreen Jul 27, 2024 Never 41
Clone
Lua paste1.txt 66 lines (53 loc) | 2.1 KB
1
-- loadstring(game:HttpGet("https://pastecode.dev/raw/7fslmbtr/paste1.txt"))()
2
3
local Player = game.Players.LocalPlayer
4
local Character = Player.Character or Player.CharacterAdded:Wait()
5
6
local function onCharacterAdded(char)
7
Character = char
8
HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")
9
end
10
11
Player.CharacterAdded:Connect(onCharacterAdded)
12
13
repeat wait() until Character and Character:FindFirstChild("HumanoidRootPart")
14
15
local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")
16
17
local coinName = "Coin"
18
19
-- Function to recursively find all coins within nested models
20
local function findCoinsInWorkspace(parent, coins)
21
for _, child in ipairs(parent:GetChildren()) do
22
if child:IsA("Model") or child:IsA("Folder") then
23
findCoinsInWorkspace(child, coins)
24
elseif child:IsA("BasePart") and child.Name == coinName then
25
table.insert(coins, child)
26
end
27
end
28
end
29
30
local function teleportToPosition(position)
31
HumanoidRootPart.CFrame = CFrame.new(position)
32
end
33
34
local function teleportToCoins()
35
local coins = {}
36
findCoinsInWorkspace(game.Workspace, coins)
37
38
if #coins == 0 then
39
print("No coins found!")
40
return
41
end
42
43
for _, coin in ipairs(coins) do
44
if coin:IsDescendantOf(workspace) then
45
-- Calculate distance to the coin
46
local distance = (HumanoidRootPart.Position - coin.Position).magnitude
47
48
if distance < 10000000 then
49
-- Teleport to the coin's position
50
teleportToPosition(coin.Position + Vector3.new(0, 0, 0)) -- Offset to avoid overlap
51
-- Wait a short delay before moving to the next coin
52
wait(0.05) -- Adjust delay as needed
53
else
54
print("Coin is too far:", coin.Name)
55
end
56
else
57
print("Coin is not in the workspace anymore:", coin.Name)
58
end
59
end
60
end
61
62
-- Continuously teleport to coins in a loop
63
while true do
64
teleportToCoins()
65
wait() -- Adjust delay between loops if needed
66
end