Hello!, I’m having trouble using this script I made, the while loop will run 2 times and the for loop 2 times, it gets stuck before starting the while loop again as you can see in the output;
Here is the script, any help would be appreciated.
while true do
wait()
print("while")
for i, v in pairs(game.Players:GetPlayers()) do
print("for")
local character = v.CharacterAdded:wait()
character.ChildAdded:Connect(function(child)
if child.Name == "Owner" then
print("child added")
listenerevent:FireAllClients()
end
end)
end
PlayersService.PlayerRemoving:Connect(function(funado)
print("funado")
listenerevent:FireAllClients()
end)
end
The thing is I’m making a tycoon, and when the player touches the owner door, the player gets a owner “tag” that is just a value inside the player character, I need to listen to when this value is added.
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
z = character.ChildAdded:Connect(function(child)
if child.Name == "tag or whatever" then
-- do whatever
z:Disconnect()
end
end)
end)
end)