Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why the player team is not changing?

Asked by
sebanuevo 123
4 years ago

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)
0
What type of instance is Deman? Bery_llium 115 — 4y
0
Deman is the name of a textbutton sebanuevo 123 — 4y
0
you have to specify a character to load, it cant just be blank matiss112233 258 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

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)
Ad

Answer this question