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

Change team from part hit?

I've tried making a script in which where you step on a button, and when you step on it, it changes your team. But I don't know how to do it :/

script.Parent.Touched:connect(function(part)
	local player = part.Parent.Name
	game.Players.player.TeamColor = Color3.new("New yeller")
end)

1 answer

✓ Accepted answer

You could use the :GetPlayerFromCharacter method.

script.Parent.Touched:connect(function(Obj)
	local player = game.Players:GetPlayerFromCharacter(Obj)
	if player ~= nil then -- credit to Sponge, and XAXA
		player.TeamColor = BrickColor.new("New Yeller")
	end
end)

2 comments

2

You should probably check if player isn't nil before setting the TeamColor so that the script doesn't error if there's no player.

0

TeamColor must be a BrickColor value.

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