Hey so i think this is possible as i have seen it in games before but i cannot figure out how to do it, i want to make it so when a player dies say 3 times a function triggers which say turns on a certain gui for x amount of time.
How would i do this, thank you in advance?
You could store a Number variable for every player that joins the game, and check when the Character Model dies using the Humanoid.Died Event
It’s actually pretty simple to pull off, all you just need to listen for is when Players, and Characters get added to the server using PlayerAdded
/CharacterAdded
Events
It’s advised to handle this on the server’s side, preferably in ServerScriptService for exploit reasons:
local Players = game:GetService("Players")
local DeathRequirement = 3
local function FireCustomFunction(PlrGui)
--Do your Gui configuration here
end
Players.PlayerAdded:Connect(function(Plr)
local PlayerDeaths = 0
local PlrGui = Plr:WaitForChild("PlayerGui")
Plr.CharacterAdded:Connect(function(Chr)
local Hum = Chr:WaitForChild("Humanoid")
Hum.Died:Connect(function()
PlayerDeaths += 1
if PlayerDeaths == DeathRequirement then
FireCustomFunction(PlrGui)
end
end)
end)
end)
1 Like
I would also say that when the gui gets triggered, the death counter should reset back to 0, otherwise the gui won’t fire again.
1 Like
Thanks very much for this it works perfectly.
Also in response to @eatabler0ck i simply added PlayerDeaths -= DeathRequirement
after FireCustomFunction(PlrGui)