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

Team Switch Button GUI Switches Team But, Confines Player To Lobby Spawn?

Asked by 5 years ago

I am currently build a sort of "raid fort", teams as you could guess plays a major role matchmaking. So I decided to make GUI buttons off to the side of the screen that by clicking them allows you to switch to either team. I have one issue though, despite switching the player to the other team it confines them to the lobby spawn even when the player is killed and spawned.

https://imgur.com/a/959zKHM https://imgur.com/a/MCJwvQ3

I first thought that the spawns of red and blue team might be the problem but, after checking, there didn't seem to be any problems. Here is the two local scripts that are inside of both team changing buttons as well as the explorer view of the starter GUI.

function onButtonClicked()
script.Parent.Parent.Parent.Parent.Parent.Character.Humanoid.Health = 0
end

script.Parent.MouseButton1Click:connect(onButtonClicked)
function Click(mouse)
script.Parent.Parent.Parent.Parent.Parent.TeamColor = BrickColor.new("Bright red")
end


script.Parent.MouseButton1Down:connect(Click)

https://imgur.com/a/pVad3L3

It's essentially the same for both the red and blue buttons, except the blue button is set for the color "Bright blue" instead of "Bright red"

0
are you sure the spawnlocations aren't neutral? SulaymanArafat 230 — 5y

1 answer

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

NOTE: This does not need to be a server-side (local) script. It can just be a client-side (plain, non-local, non-module, regular, "Script")

local Player = script.Parent.Parent.Parent.Parent.Parent -- USE THESE!

function onButtonClicked()
    Player.TeamColor = BrickColor.new(--[["Bright red" or "Bright blue"--]])
    Player:LoadCharacter() -- instead of killing the player, just load a completely new character AFTER the team change.
end

script.Parent.MouseButton1Click:connect(onButtonClicked) -- Why not combine into ONE script?

Then, in the Bright Red teams' spawn:

script.Parent.Neutral = false script.Parent.TeamColor --[[ or Team, im in scripting Helpers --]] = BrickColor.new("Bright Red")

Same thing with the Bright Blue's team.

script.Parent.Neutral = false script.Parent.TeamColor --[[ or Team, im in scripting Helpers --]] = BrickColor.new("Bright Blue")

0
I switched around scripts and made edits according to your comments however, it worked in studio but unfortunately did not work in-game. User#19159 0 — 5y
0
Weird. Plain weird. GamingZacharyC 152 — 5y
0
I am making an edit. Hold on. GamingZacharyC 152 — 5y
0
done. GamingZacharyC 152 — 5y
View all comments (2 more)
0
Thank you! I won't say adding in "Player:LoadCharacter" didn't work in studio. However, it still did not work in game with FE. It works fine without FE, which wouldn't be a problem but FE is kind of required because of the recent update. User#19159 0 — 5y
0
k. GamingZacharyC 152 — 5y
Ad

Answer this question