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

How to Functional Team Change Script [FE Compatible] Issues & More?

Hi,

I'd like to first introduce my problem. I've tried many variations & ways to create a functional FE team changing script & all of them fail to work.

Problems consisting of these

  • Server-Sides only (other players don't see it)
  • Player spawn doesn't work
  • Or Simply won't work

I've worked on remotes, etc.. I do on the other hand have a GUI system to use for the team changing, but it's pointless if it doesn't work. I have my game FE on.

Tutorials I've tried:

https://www.youtube.com/watch?v=C6LKaa10Zog&t=22s https://www.youtube.com/watch?v=deYNxV9-vpI&t=320s

etc...

My goal is to create a gamepass team, and once the user who clicks the button & doesn't have a gamepass it prompts purchase.. I think I got that part covered from a different question on this site.

Best Progress.. [NON FE]

local team = script.Parent.Team
local player = game.Players.LocalPlayer
local Timer = script.Parent
-- The Timer is completely unrelated/uneccessary to the function of the team changing fyi.
-- The Value is in the Team (Object Value) to ID the team name
script.Parent.MouseButton1Click:Connect(function()
	script.Parent.Timer.Visible = not script.Parent.Timer.Visible
	wait(3)
	player.Team = team.Value
	player.Character.Humanoid.Health = 0
end)

Problems w/ this script.. Other players don't see the change.. Spawns don't work for some reason..

Thank you! I will appreciate the help :)

2 comments

0

Make sure you're handling the change through a server script, as a local script wouldn't replicate.

0

Please listen to the above comment.

1 answer

✓ Accepted answer

You need to use a remote as you're currently changing the player's team through a localscript so it does not replicate to the server. What it would look like:

local team = script.Parent.Team
local player = game.Players.LocalPlayer
local Timer = script.Parent
local changeTeam = game:GetService("ReplicatedStorage").changeTeam
-- The Timer is completely unrelated/uneccessary to the function of the team changing fyi.
-- The Value is in the Team (Object Value) to ID the team name
script.Parent.MouseButton1Click:Connect(function()
    script.Parent.Timer.Visible = not script.Parent.Timer.Visible
    wait(3)
	changeTeam:FireServer()
end)

ServerScript:

game:GetService("ReplicatedStorage").changeTeam.OnServerEvent:Connect(changeTeam)

function changeTeam(player)
	player.Team = path.ToTeam
end

1 comment

1

So I've updated the script, I've created the remote with the same name & added the serverscript in the serverscriptservice. I don't understand the player.Team = path.ToTeam. It's underlined red. Let's say my team name is Blue & how would I change it to that based off BrickColor or Team Name(preferbally)

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