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

Team Switch GUI Switches Team But, Still Confines Player to Lobby Spawn?

Asked by 5 years ago
Edited 5 years ago

I made a recent question with the same topic. However I am still having the same problem, I originally fixed it by turning off FilteringEnabled. However, FE is now a must, do to recent updates. The team switch script works just fine, it switches your team and doesn't have any difficulties.

--This is a local script
local player = game.Players.LocalPlayer

function onButtonClicked()
    player.TeamColor = BrickColor.new("Bright red")
end

script.Parent.MouseButton1Click:connect(onButtonClicked)

Unfortunately, the kill script works, except it doesn't respawn you at the intended team spawn, instead it keeps you at the lobby spawn even if you click it repeatedly. Not only that but, the system in place that's supposed to -1 to your Wipeouts when you click the team switch button also doesn't work. Here is the script for this...

--This is a normal script
player = game.Players.LocalPlayer

function onButtonClicked()
script.Parent.Parent.Parent.Parent.Parent.Character.Humanoid.Health = 0
    player.leaderstats.Wipeouts.Value = player.leaderstats.Wipeouts.Value - 1
end

script.Parent.MouseButton1Click:connect(onButtonClicked)

I am extremely inexperienced when it comes to integrating Filtering Enabled, I understand you are supposed to use RemoveEvents and RemoveFunctions but I don't know exactly how to use those when it comes to these scripts or really how to properly use them at all.

EDIT: I managed to get it working properly in studio to where it spawns you in the corresponding spawn and doesn't confine you to the lobby. I used this tutorial to do it: https://www.youtube.com/watch?v=wic-N4JiFss&t=559s. However, I was not able to get it working in game despite using remote events and all. When I clicked the buttons they didn't even do anything at all.

0
Your first problem is you can't use LocalPlayer in a normal script. dirk2999 103 — 5y
0
What's a normal script? User#19524 175 — 5y
0
What do you suggest I replace "LocalPlayer" with? User#19159 0 — 5y
0
What's a normal script? @forceoh777 User#19524 175 — 5y
View all comments (3 more)
0
That's a script. No such thing as a normal script exists. User#19524 175 — 5y
0
By normal script, I meant a non-modular and non-local, plain, normal script. User#19159 0 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

Hi!

I am pretty sure teamswitching isn't allowed via a LocalScript. Considering everybody in the game needs to see you on the other team, a LocalScript changes it only for your client.

There is, however, a way to use it. I recommend you to look into RemoteEvents. They allow LocalScripts to execute Server-sided Scripts (such as your teamswitch). You can find more about that here, or somewhere on YouTube probably.

So yeah, it's completely normal for you to spawn on the old team's spot, because according to the server and other players, you're still on the old team!

Using a RemoteEvent would allow you to switch teams via the LocalScript, and allowing everyone else to see it aswell.

Hope this helps and good luck!

0
The main reason it's a local script is because it doesn't work in-game if it isn't. So yeah...looking more into remote events hopefully will fix it. Thank you! User#19159 0 — 5y
Ad

Answer this question