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