Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why is my team changer script not switching players properly to their teams??

Asked by 6 years ago
Edited 6 years ago

So I made a GUI for changing teams. I have the script to change to the "Electric blue" team and the "Deep orange" team. It shows that it switches you, but in the game it's only you that have switched teams even though others have probably. Also, your chat is deep orange, since when you spawn in your team is automatically deep orange.

The script is in StarterGui.ScreenGui.Frame.Textbutton.Localscript

Script to switch to the Electric blue:

local player = game.Players.LocalPlayer
repeat wait() until player.Character
Character = player.Character
Character:WaitForChild("Humanoid")

script.Parent.MouseButton1Click:connect(function()
    player.TeamColor = BrickColor.new("Electric blue")
    game.Players.LocalPlayer.Character:MoveTo(Vector3.new(-103.8, 94.62, -159))
end)

The script for Deep orange is the same, just replace line 7 with player.TeamColor = BrickColor.new("Electric blue") with "Deep Orange"

I have a feeling it has something to do with WaitForChild, but I wasn't too sure, so I added the code in lines 2-4

EDIT: I have filtering enabled on, but it's still not switching the player's team's. Here's my local script:

local player = game.Players.LocalPlayer
script.Parent.MouseButton1Click:connect(function() --Put the script into the textButton you want to click
    game.ReplicatedStorage.RemoteEvent:FireServer()
end)

and here's my script that receives the remoteevent but it doesn't switch the teams still.

game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(player)
    player.TeamColor = BrickColor.new("Electric blue") --Change the name to the team you want.
    game.Workspace[player.Name].Torso:Destroy() --You can change it so that the player doesn't die to whatever you like.
end)

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

What I use is a lot different but it still works.

local player = game.Players.LocalPlayer

script.Parent.MouseButton1Click:connect(function() --Put the script into the textButton you want to click
player.TeamColor = BrickColor.new('Electric blue') --Change the name to the team you want.
    game.Workspace[player.Name].Torso:Destroy() --You can change it so that the player doesn't die to whatever you like.
end)

I hope this helps!

0
Nope, doesn't work for me, any other ideas? warfighter10000 4 — 6y
0
I just thought, do you have filtering enabled on your game? DogeDark211 81 — 6y
0
yes i do warfighter10000 4 — 6y
0
Oh, it works with filtering enabled off, but do you know a solution while it's on? warfighter10000 4 — 6y
View all comments (3 more)
0
No, I am still learning how to script in general so I don't know much, all I really know is that you have to use remote functions or remote events. DogeDark211 81 — 6y
0
alright, I'm learning as well, thanks for your help warfighter10000 4 — 6y
0
No problem. DogeDark211 81 — 6y
Ad

Answer this question