Hey all, I have this script that just updates a gui if a player dies, it checks what team they are on. It did work before, but I realised that I need for it to check in case a spectator resets.
Basically all it does it checks how much people are in a team. Ive got the update event working, but when a person dies it does nothing, now this has two scrips because I don’t know which one of them is not working.
Edit: forgot to mention but no output errors
Edit 2: forgot to mention again, but just tried this:
For the serverscript, at
if player.Team == Teams{“Survivor”} then
I have tried using {}, [], and (). Nothing worked as in the script didn’t produce any output errors and didn’t work.
Client side, in startergui with “plrcount” as a child
local Teams = game:GetService("Teams")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = ReplicatedStorage:WaitForChild("plrcount")
local remoteEventv = ReplicatedStorage:WaitForChild("update")
local text = script.plrcount.Frame.TextLabel
local function onTimerUpdate(value)
print("died")
script.ambient1:Play()
wait(.2)
print(value)
text.TextColor3 = Color3.new(0, 0, 0)
script.plrcount.Frame.TextLabel.Text = "Players Remaining: ".. value
text.TextColor3 = Color3.new(0.568627, 0, 0)
wait(.5)
text.TextColor3 = Color3.new(0, 0, 0)
wait(.5)
text.TextColor3 = Color3.new(0.568627, 0, 0)
wait(.5)
text.TextColor3 = Color3.new(0, 0, 0)
wait(.5)
text.TextColor3 = Color3.new(0.568627, 0, 0)
wait(.5)
text.TextColor3 = Color3.new(0, 0, 0)
end
local function update(plrvalue)
script.plrcount.Frame.TextLabel.Text = "Players Remaining: ".. plrvalue
end
remoteEvent.OnClientEvent:Connect(onTimerUpdate)
remoteEventv.OnClientEvent:Connect(update)
Server side, in serverscriptservice
local playersOnTeam = game:GetService("Teams")["Survivor"]:GetPlayers()
local numberPlayersOnTeam = #playersOnTeam
local Teams = game:GetService("Teams")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = ReplicatedStorage:WaitForChild("plrcount")
local remoteEventv = ReplicatedStorage:WaitForChild("update")
script.remain.Value = #playersOnTeam
local value = script.remain.Value
remoteEventv:FireAllClients(value)
game:GetService('Players').PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
character:WaitForChild("Humanoid").Died:Connect(function()
if player.Team == Teams{"Survivor"} then
print("sir had died")
script.remain.Value = script.remain.Value - 1
local value = script.remain.Value
remoteEvent:FireAllClients(value)
end
end)
end)
end)
Any help is great, thanks!