I’m trying to make a 2XCOINS boost in my game and I have tried multiple solutions but I want the GUI to be visible at all times and even after death
When you reset character/die the GUI for the boost disappears but the boost keeps running and counting
I have tried checking for humanoid death but it didn’t work, I looked for somebody with a similar problem on the dev forum and it didn’t help me
even tried AI but it just made it worse
This is the server script that handles boost functions
game.Players.PlayerAdded:Connect(function(plr)
local data = plr:WaitForChild("Data", 10)
local hasBoost = data:FindFirstChild("Has2xBoost")
local boostDuration = data:FindFirstChild("BoostDuration")
local isCountingDown = false
local playerGui = plr:FindFirstChild("PlayerGui")
local boosterGui = playerGui:WaitForChild("BoosterGuis")
local BOOSTIMAGE = boosterGui:FindFirstChild("Boostersall"):FindFirstChild("ImageLabel")
local BoostTEXT = BOOSTIMAGE:FindFirstChild("TextLabel")
local function Boost()
isCountingDown = true
BOOSTIMAGE.Visible = true
while boostDuration.Value > 0 and BOOSTIMAGE.Visible == true do
task.wait(1)
boostDuration.Value -= 1
BoostTEXT.Text = tostring(boostDuration.Value) .. "s"
print("Boostworking")
end
BOOSTIMAGE.Visible = false
hasBoost.Value = false
isCountingDown = false
end
if hasBoost.Value and boostDuration.Value > 0 then
Boost()
end
boostDuration:GetPropertyChangedSignal("Value"):Connect(Boost)
end)
This is the script inside a part that makes the value true and sets duration
local boostPart = script.Parent
local boostDuration = 60 --seconds
boostPart.Touched:Connect(function(hit)
local character = hit.Parent
local player = game.Players:GetPlayerFromCharacter(character)
if player then
local data = player:FindFirstChild("Data")
if data then
local coins = data:FindFirstChild("Coins")
local hasBoost = data:FindFirstChild("Has2xBoost")
local boostDurationValue = data:FindFirstChild("BoostDuration")
if hasBoost and boostDurationValue then
hasBoost.Value = true
boostDurationValue.Value = boostDuration
end
end
end
end)
Reset on spawn is OFF!!