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

team dosent change for a specific team, how to fix?

im making this team changer brick but i want to change team if you are an other specific team

here the script

local player = game:GetService("Players").LocalPlayer

script.Parent.Touched:Connect(function(hit)
	local user = game.Players:GetPlayerFromCharacter(hit.Parent)
	if user.Team == 'clandestin' then
		user.Team = game:GetService('Teams'):FindFirstChild('cittadino')
end
end)

there is no error showing

2 comments

0

Is this a local script or server script?

0

a script in a brick

1 answer

✓ Accepted answer

Local player will not work on the server as the server isn't associated with any of the clients so it's only going to return an error if you try it on the server. Also, you should be using the Teams service instead of comparing the player's team to a string, you should be comparing it to the team object itself.

local Teams = game:GetService("Teams")

script.Parent.Touched:Connect(function(hit)

	local User = game.Players:GetPlayerFromCharacter(hit.Parent)
	if User then
		if User.Team == Teams.clandestin then
			User.Team = Teams.cittadino
		end
	end
end)

1 comment

0

thank you very much

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