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

[Solved] How can you a spectate GUI that disables when your in a match?

Asked by 5 years ago
Edited 5 years ago

So I've been searching for scripters, tutorials, and players but I haven't got any success. Basically, the Spectate GUI works fine; however, players are able to spectate other players while in a match which is unfair to others.

I've gotten a reply before and it goes: "If you don't want teams, I would create a value inside the player when he joins called "playing" or something, then set that value to true when the player is added to the game, that way you can check if the player is playing or not." - TheGreenSuperman

I appreciate his comment but I am new the scripting world and is confused by his terms. What does this mean?

0
SH is not for requests. The answer you recieved is a fine way to go about it. DinozCreates 1070 — 5y

2 answers

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

That's a good suggestion, and it's probably what I would do. You can do this with actual instances or table values. Here's an example with a BoolValue:

Server script:

game:GetService("Players").PlayerAdded:Connect(function(plr)
  local IsInMatch = Instance.new("BoolValue")
  IsInMatch.Name = "IsInMatch"
  IsInMatch.Parent = plr
  --somewhere in your script, you'll have to set this value to true (like when you click a spawn button or something)
end)

Local script:

local plr = game:GetService("Players").LocalPlayer

plr.CharacterAdded:Connect(function(char)
  local IsInMatch = plr:WaitForChild("IsInMatch")
  if IsInMatch.Value == true then
    plr.PlayerGui.SpectateGui.Enabled = false --example
  end
end)
Ad
Log in to vote
0
Answered by
Mr_Pure 129
5 years ago
Edited 5 years ago

Just create a few bool(true or false) values such as

IsSpectating and IsPlaying. (you can put these values in an accessible spot[preferably in the player])

When the match starts Set IsPlaying to true if he/she plans to participate this round, then use a conditional statement:

if IsPlaying and not IsSpectating then
    --continue the code
elseif IsPlaying and IsSpectating then
    --Revert his camera
end

i really don't know how else to explain it to you.

Answer this question