Team Changer, not working right [ Fixed ]

Hello, so recently I added a team changer to my game, and have come to an issue with it

I don’t really know why but the scripts work right, but it only affects the client, so it would only show the person itself that the team has been changed. So if they would change their team, it would only be seen by them and they would stay on the team they were spawned with

I have tried to change the team changer, I have tried some but the problem still goes by can someone help me find out how to fix this issue? Thank you

Team Changer, Button Code

Localsctript

	if script.Parent.Parent.Parent.Parent.Parent:IsInGroup(15463794) then
		script.Parent.Parent.Parent.Parent.Parent.TeamColor = BrickColor.new("Deep orange")
	end
end

script.Parent.MouseButton1Click:connect(Click)

Use a ServerSCript, a regular script

1 Like

In a local script, everything done will only be seen by the client

1 Like

Changes made using a local script only appear for the player themselves. If you want to make the changes appear on the server remote events are used.

If it sounds confusing let me know and I’ll give you an example script.

I advise checking this out as well:

https://devforum.roblox.com/t/how-do-you-make-a-team-change-gui/406396/7?u=un1nd3x

it’s a good documented script for this purpose that I wrote a few years ago

1 Like

Alright thanks everyone, Ill test it out

you need to use remote events it would look like this.

-- LocalScript
script.Parent.MouseButton1Click:Connect(function()
game.ReplicatedStorage.Remote:FireServer() -- Firing The Remote to the server to create connection between the server & client
end)
-- ServerScript
game.ReplicatedStorage.Remote.OnServerEvent:Connect(function(plr)
if plr:IsInGroup(15463794) then -- Checking if the player is in the Group "15463794"
		plr.Team = TeamHere -- changing the player's team to "YourTeam"
	end
end)
1 Like
if script.Parent.Parent.Parent.Parent.Parent:IsInGroup(15463794) then --checking
 
		local event = game.ReplicatedStorage.RemoteEvent           
                 event:FireServer(Click) -- Fire the event
	end
end

script.Parent.MouseButton1Click:connect(Click) -- event

–Local Script

1 Like

It’s working now, thank you everyone for the help I’m new to scripting!

2 Likes

np! if you have any questions feel free to ask :smiley:

1 Like

You should also use variable to assign the player and for reduce lags in your game

1 Like

there is no need of a variable for the “plr” in here.
since firing the remote to the server already provides the player Instance.

2 Likes