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?
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)
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.