Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do I make this constantly update the playerbase?

So, I got this script so that when someone says "Help" they tp to me.

mk = game.Players:GetChildren()
for i=1, #mk do
mk[i].Chatted:connect(function(Msg)
if Msg == "Help" then
mk[i].Character.Torso.CFrame = CFrame.new(Workspace.jaytheidiot.Torso.CFrame.X+5,Workspace.jaytheidiot.Torso.CFrame.Y+2,Workspace.jaytheidiot.Torso.CFrame.Z)
end
end)
end

How do I make it so the playerbase is constantly updated? With this only the people who were there when I ran it can use it.

1 answer

✓ Accepted answer

An easy way to fix this is to put the whole thing in an infinite loop. That way, every 0.01 seconds or so it will check the list of players again.

while true do
	wait()
	local mk = game.Players:GetChildren()
	for i=1, #mk do
		mk[i].Chatted:connect(function(Msg)
			if Msg == "Help" then
				mk[i].Character.Torso.CFrame = CFrame.new(Workspace.jaytheidiot.Torso.CFrame.X+5,Workspace.jaytheidiot.Torso.CFrame.Y+2,Workspace.jaytheidiot.Torso.CFrame.Z)
			end
		end)
	end
end

This discussion is preserved as it was. New answers, comments, and votes are closed.