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

Remote Events and Team Changing?

I can change teams but people in the game don't see the team I switch too.

I used a Remote event and it's not working..

In replicated storage I named a event [Team Change]

And now it's not working.

Thanks for helping the future obby builder

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local createPartEvent = ReplicatedStorage:WaitForChild("Team Change")



local player = game.Players.LocalPlayer

script.Parent.MouseButton1Click:connect(function()
 player.TeamColor = BrickColor.new("Black")

end)

2 answers

✓ Accepted answer

If the problem is the same as in this question from 2 days ago, then the reason it didn't work is that you didn't actually fire the RemoteEvent. (call the FireServer method). This is how you would use a RemoteEvent.

Also, like the other answer said, always test on Server mode, as Using the blue "Play" button is unreliable, and is an inaccurate representation of what would happen in online mode, (when people will actually play your game) with Servers and Clients, which is why people get the "works in studio, but not in game" issue.

The following method would work, provided that there is a RemoteEvent in the ReplicatedStorage called "Team Change", which, as you said, is true. However, to make things easier, it's best not to name things with spaces. That being said though, this way would work with "Team Change"

In a Script in the ServerScriptService

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local createPartEvent = ReplicatedStorage:WaitForChild("Team Change")

createPartEvent.OnServerEvent:Connect(function(player,teamcolor)
	player.TeamColor = teamcolor
end)

In the LocalScript inside the GUI

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local createPartEvent = ReplicatedStorage:WaitForChild("Team Change")

local player = game.Players.LocalPlayer

script.Parent.MouseButton1Click:Connect(function()
	createPartEvent:FireServer(BrickColor.new("Black"))
end)

1 comment

0

thank you! i hope you play my obbys one day to show the work you've helped me with ;)

You should not rely on studio's test mode, It's not the same as the actual game. I assume you know the difference between Client and Server, if not, you should read this.

Assuming your script is a LocalScript, the reason why other players can't see your change is because of a very simple reason: You did it Client-Sided.

The Server-Side makes sure that everything that happens in the server is replicated to every player in the game, and every player has a Client-Side, however, the Client-Side doesn't replicate what happens in it to the server. Now, if you create a part in a Server-Script (Or Normal Script), the part will be server-sided and the Server-Side replicates everything to the Client-Side so we can see the change, BUT if we create a Part from a LocalScript inside...I dunno...PlayerGui, since the Client-Side doesn't replicate its stuff to the server, the part will be client-sided, and since it isn't replicated to the server and then to the other players, the player that created the part will be the only one that will see the part.

Same happens with your script, You're changing your team Client-Sided, it doesn't replicate to the other players so you're the only one that will see the change. I highly recommed you checking this to help you what to do. Good luck.

1 comment

0

P.S: Read carefully everything so you get an idea of what to do.

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