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

Why the player team is not changing?

I followed alvin blox tutorial on team change gui but why this doesnt work?

Local script inside startergui:

local frame = script.Parent.Frame
local remote = game.ReplicatedStorage.RemoteEvent

frame.Deman.MouseButton1Click:Connect(function()
	remote:FireServer()
end)




script.Parent.TextButton.MouseButton1Click:Connect(function()
	script.Parent.TextButton:Destroy()
	frame.Visible = not frame.Visible
end)

Listener Script:

local remote = game.ReplicatedStorage.RemoteEvent
local teamcolor = BrickColor.new("Maroon")

remote.OnServerEvent:Connect(function(player)
	player.TeamColor = teamcolor
	player:LoadCharacter()
end)

3 comments

0

What type of instance is Deman?

0

Deman is the name of a textbutton

0

you have to specify a character to load, it cant just be blank

1 answer

✓ Accepted answer

Edit: post fix

Usually, changing teams won't show up on Studio but yes the team is applied to the player. I always encounter this when I was making my game, The Fun Mayhem.

First you need to get the Teams object to the DataModel (or the game root), then you can choose to create a team automatically via script or manually

You MUST put the team on the Teams object at the DataModel in order for teams to work!

Manually:

--// Assuming you have a team named Players with the color Maroon located at game.Teams.
local playersTeamColor = BrickColor.new("Maroon")

local remote = game.ReplicatedStorage.RemoteEvent
remote.OnServerEvent:Connect(function(player)
	player.TeamColor =  playersTeamColor
	player:LoadCharacter()
end)

Automatically:

--// Create a team
local playersTeam = Instance.new("Team")
playersTeam.TeamColor = BrickColor.new("Maroon")
playersTeam.Name = "Players"
playersTeam.Parent = game.Teams

local playersTeamColor = BrickColor.new("Maroon")
remote.OnServerEvent:Connect(function(player)
	player.TeamColor = playersTeamColor
	player:LoadCharacter()
end)

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