I tried to make the script print the distance between the player and the part; It only prints out one value.
Here’s the code:
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(plr)
local char = plr.Character or plr.CharacterAdded:Wait()
local humanoidRoot = char:WaitForChild("HumanoidRootPart")
local partfolder = workspace.Folder
for _,v in pairs(partfolder:GetChildren()) do
while wait() do
local distance = (humanoidRoot.Position - v.Position).magnitude
while wait(1) do
print("You are " .. distance .. " studs away from the part!")
end
end
end
end)
Here’s a video of it not working:
If you can help, please do. All help is appreciated!
for _,v in pairs(partfolder:GetChildren()) do
task.spawn(function()
while task.wait(1) do
local distance = (humanoidRoot.Position - v.Position).magnitude
print("You are " .. (math.floor(distance*100/100)) .. " studs away from the part!")
end
end)
end
(math.floor(distance*100/100)) is just so instead of you having a number like 24.549684359, you have 24.54