How to make my Team Change, Filtering Enabled

Hello, I am trying to make my team change work with filtering enabled and I was told I need to use RemoveEvents in the ReplicatedStorage and then use a script in ServerScriptService to make them work, but I am having trouble getting them to work, can anyone help?

Here is what my GUI looks like
image

Any help is greatly appreciated.

3 Likes

It’s better if you post what code you already have…
Client code is more of an example.

-- server
local teams = game.Teams
local changeTeam -- remote

changeTeam.OnServerEvent:connect(function(player, name)
	local team = teams:FindFirstChild(name)
	if team then
		player.Team = team
	end
end)

-- client
local changeTeam -- remote
local button

button.MouseButton1Click:connect(function()
	changeTeam:FireServer(button.Name) -- or whatever you come up with to define what to send
end)
8 Likes

Do you still need the code in it?

1 Like

I don’t need the code. What I’ve given you for the server code is complete, use what I gave you to finish the client side.

1 Like

Do I put the code in ServerScriptService or my Team Change UI

1 Like

The server code should be put in ServerScriptService, you can assume this for most code. Though as with anything, you may find exceptions, just use judgement.

1 Like

Thanks

1 Like

Hey sorry to bother you again, but it’s about the script. Do I put the client code inside my GUI or do I also put it in the ServerScriptService

1 Like

Client code goes in the GUI.

Rather than learning what code works for this specific case, it would be more beneficial for you to learn how remotes work.

1 Like

That’s exactly what I did, I put the client code in a local script inside the UI and it still doesn’t work, no matter how many times I click it. It works in test mode but not in game. Any advice?

1 Like

Add a print to the client/server to debug (see which is not firing).

1 Like

How can I check what isn’t firing?

1 Like

You would check the output online for the prints (F9), if the local logs don’t show a print you know it’s that.

1 Like

Actually it works now, however I don’t re-spawn after I change my team. Is there something I can add so I respawn

1 Like

Player:LoadCharacter()

1 Like

It doesn’t seem to work.
https://gyazo.com/449ac384d448cc1e8ddddb552ff56c1b

This is the code I have inside of the textbutton:

Player = script.Parent.Parent.Parent.Parent.Parent

local GroupId = 1245097

script.Parent.MouseButton1Down:connect(function()
	if Player:IsInGroup(GroupId) then
		Player.TeamColor = BrickColor.new("Bright blue")
		Player:LoadCharacter()
	end
end)
2 Likes

On the server :\

At some point you have to help yourself and look it up

1 Like

To make your team change FE compatible as you already know you basically want a script that calls a remote event to change the team to whatever it is
when using a remote it already has the player put into the value so you dont need to send that over also load character doesnt working with local scripts you could load the player using the script that handles changing the team.

5 Likes