What I am trying to do with this script is to bring up a pop-up when the amount of deaths in a row is at a certain number. The problem is that the deaths in a row which is a variable won't add up. I have tried to debug it with print and have changed the variable into an int value. Also, the script is located in StarterCharacterScripts.
local Id = 1166304573
local player = game.Players.LocalPlayer
local character = script.Parent or player.Character
local humanoid = character.Humanoid
local Stage = player:WaitForChild("leaderstats"):WaitForChild("Stage")
local DeathsInARow = 0
local LastStage = Stage.Value
Stage.Changed:Connect(function()
if LastStage ~= Stage.Value then
print("Reset")
DeathsInARow = 0
LastStage = Stage.Value
end
end)
humanoid.Died:Connect(function()
print("Humanoid is ded")
if LastStage == Stage.Value then
DeathsInARow = DeathsInARow + 1
print("Deaths In Row: "..DeathsInARow)
print("Last Stage: "..LastStage)
if DeathsInARow >= 2 then--change to 6 later
print("Need Help?")
game:GetService("MarketplaceService"):PromptProductPurchase(player, Id)
end
end
end)

7 comments
Any errors in the output?
No
what are your prints saying?
Humanoid is ded, Deaths In Row: 1(and it stills stays at one), Last Stage: 1(and it all happens over and over again and doesn't change)
Local Scripts only updates the values Locally(client only), so that changes aren't replicated to server. You should use a server script instead of a client one(some changes will be needed to code)
ok
I FOund this in the unanswered section when it is answered XD