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

Remote Event not changing team (FE)?

For some reason this is not changing my team, it kills me though so I know that remote event works. How would I fix this?

Server Script

script.TeamChangeEvent.OnServerEvent:connect(function(player, team)
	player.Team = game.Teams:FindFirstChild(team.Name)
	player.Character.Humanoid.Health = 0
end)

Local Script

local Team = script.Parent.Name
game.Workspace:WaitForChild("TeamChange"):WaitForChild("TeamChangeEvent"):FireServer(Team)

1 answer

✓ Accepted answer

You posted the same question twice, so here's the same answer twice lol. You can have a remote **function **called 'ChangeTeam' inside ReplicatedStorage, then a script like this in ServerScriptStorage:

local remote = game.ReplicatedStorage.ChangeTeam

function remote.OnServerInvoke(player, TeamName)
	player.TeamColor = BrickColor.new(TeamName) -- Please note that this is how you switch roblox teams.
	player.Character.Humanoid.Health = 0 -- I just added this because it seems you want to kill the player
end

So what the code above does is simple. Once invoked, it gets 2 pieces of information. The player, and the Team name. Then it changes the player's team. You can invoke this remote function to change any player's team from the client with FE on, and it does not matter which team you want them to be. Now, you just need to Invoke it.

--at the start of the script
local remote = game.ReplicatedStorage.ChangeTeams
--now invoke it when wanted to in the script:
remote:InvokeServer("Dark blue") -- This will send "Dark Blue" as the 'TeamName' (It's just the Team color to be exact) change Dark Blue to what you want it to be, from one script to another.

Now you have a FE change teams system! All you need is the first script, the RemoteFunction, and the knowledge of adjusting the 2nd script to what you want.

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