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

Why does this RemoteEvent script respawn a player but not team them?

Can anyone tell me why this RemoteEvent script respawn's the player but doesn't team them? I know I could use game.Players.LocalPlayer.TeamColor = game.Teams.TestTeam.TeamColor or whatever but that doesn't work with FilteringEnabled. Any help appreciated.

Script for when it's fired(In a ServerScript in ServerScriptService):

local Event = game.ReplicatedStorage.ChangeTeam

Event.OnServerEvent:connect(function(Player,Team)
	Player.TeamColor = Team.TeamColor
--	wait(0.30)
	Player:LoadCharacter()
end)

Script to fire it(In a LocalScript):

local Event = game.ReplicatedStorage.ChangeTeam

script.Parent.MouseButton1Click:connect(function()
	Event:FireServer(game.Players.LocalPlayer,game.Teams.TestTeam)
end)

1 comment

2

Take out the first argument in the Localscript. When you are firing a server, it is already passing the player as an argument. See if that works

1 answer

✓ Accepted answer

##Problem

It's because with RemoteEvents and RemoteFunctions, the Server automatically gather's the client who fired or invoked the object.


##Solution

All you have to do is remove the first argument you placed in the FireServer function one line three of the LocalScript.


##Final Script

local Event = game.ReplicatedStorage.ChangeTeam

script.Parent.MouseButton1Click:connect(function()
    Event:FireServer(game.Teams.TestTeam)
end)

######If you have any questions feel free to ask them in the comments below. And if this answered your question do not forget to hit the Accept Answer button.

1 comment

0

Thanks.

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