I’m working on cooldown UI for abilities in my game. The cooldown text updates every frame based on values stored in a folder inside player, like this:
runService.RenderStepped:Connect(function()
if not cooldownsFolder then return end
local now = tick()
for _, key in ipairs(keys) do
local slot = abilityBar:FindFirstChild("Slot_" .. key)
if slot then
local label = slot:FindFirstChild("CooldownLabel")
local icon = slot:FindFirstChild("Icon")
local cooldownFill = slot:FindFirstChild("CooldownFill")
local cdValue = cooldownsFolder:FindFirstChild(key)
if cdValue then
local endTime = cdValue.Value
local remaining = endTime - now
if remaining > 0 then
label.Text = string.format("%.1fs", remaining)
cooldownFill.Visible = true
if icon then icon.ImageColor3 = Color3.fromRGB(150, 150, 150) end
else
label.Text = ""
cooldownFill.Visible = false
if icon then icon.ImageColor3 = Color3.new(1, 1, 1) end
end
end
end
end
end)
In Roblox Studio the cooldown text updates as expected. But in the game, the cooldown text doesn’t even show up at all.
How can i fix this?
Check for errors on the client, since this is a localscript I’d bet the issue is with FindFirstChild, since things tend to load faster on studio than on live servers, this is a very common cause of things not working on live servers but working on studio. If there are any client errors at all send a screenshot. You could also try changing FindFirstChild to WaitForChild if there aren’t any errors on the client just to be sure
On studio but not the actual game? It’s probably a problem with some server code. Even if you get a LocalScript error, it will just keep waiting until the next frame and run this code again, so it wouldn’t matter.
But please use WaitForChild for all of these and set them to variables at the top of the script. It is the most efficient. There is also no point of using FindFirstChild if you aren’t checking if it exists or not.