So basically I have a feature in my game, you hit stuff, it breaks eventually or if its a mob it dies. I have used os.time() to attempt to make a gui disappear if you haven't hit anything for 10 seconds however it doesnt seem to be working. No errors at all. It just doesn't do what I thought it would do.
Any help in solving this problem would be greatly appreciated.
Here is my script by the way:
local rockHit = game:GetService("ReplicatedStorage"):WaitForChild("RockHit")
local lastUpdate = nil
rockHit.Event:Connect(function(p, t)
local plr = game:GetService("Players"):GetPlayerFromCharacter(p.Parent.Parent)
if lastUpdate ~= nil then
if lastUpdate + 10 < os.time() then
plr.PlayerGui:WaitForChild("ItemHealth").Enabled = false
end
end
lastUpdate = os.time()
end)

2 comments
try using wait
Wait pauses the thread and I can't do that. I rewrote the system with a few extra scripts and got it working thanks though