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

How can i pause script until player change team from neutral without using repeat wait() ?

I tried the following:

local player = script.Parent.Parent.Parent
player.Neutral.Changed:Connect()

but got an error: Players.Gulgazar.PlayerGui.PvpGui.ScriptPvPGui:10: attempt to index boolean with 'Changed'

So is there a way to do it without using smth like

repeat wait() until player.Neutral == false

?

1 answer

✓ Accepted answer

The best way to do this would be to connect to the PropertyChangedSignal of the Player's Team property. Here's an example:

game:GetService("Players").PlayerAdded:Connect(function(player)
	Player:GetPropertyChangedSignal("Team"):Connect(function()
		local team = player.Team
		if team.Name ~= "Neutral" then
			-- code here
		end
	end
end)

1 comment

0

One more question - isn't it better to use "Player:GetPropertyChangedSignal("Team"):Wait(function()" instead of :Connect? Cuz team meant to be changed only once at start in my game. Anyway, thank you :3

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