I have this script, which is in a folder, which is in a part in workspace. When I click on play, nothing happens at all and the output remains empty. It does not even print out 0. May someone please tell me what's wrong. This is my script.
for _, player in pairs(game:GetService("Players"):GetPlayers()) do print(player:DistanceFromCharacter(Vector3.new(0, 0, 0))) end
Chances are, it's because the character isn't loaded yet.
Do this instead and you should get some output:
while true do -- loop it up boiiz for _, player in pairs(game:GetService("Players"):GetPlayers()) do print(player:DistanceFromCharacter(Vector3.new(0, 0, 0))) end wait(1) -- ain't nobody got time 4 overflow end
Or:
game:GetService("Players").PlayerAdded:Connect(function(player) -- when a player joins player.CharacterAdded:connect(function() -- when le character pops in for _, player in pairs(game:GetService("Players"):GetPlayers()) do print(player:DistanceFromCharacter(Vector3.new(0, 0, 0))) end end end