Text not updating

I made this script to countdown when it gets put in workspace, but the text in the TextLabel stays as the default text and does not change?

Code:

local coin = script.Parent
local text = coin.BillboardGui.TextLabel

coin.AncestryChanged:Connect(function()
	if game.Workspace:FindFirstChild(coin) then
		for i = 1, 60 do wait(1)
			text.Text = string(60 - i)
		end
		coin:Destroy()
	end
end)
1 Like

Change string(60-i) to tostring(60-i)

1 Like

This didn’t work, i don’t think that part is the problem

1 Like

if game.Workspace:FindFirstChild(coin.Name) then

The findfirstchild search by name

1 Like

The issue is most likely in your conditional. FindFirstChild() does not work by finding instances, but by finding names. If the coin is called “coin” and you did workspace:FindFirstChild("coin") then it would work. However, I’m assuming you need to determine if that specific coin is in the workspace, so instead you could use the second parameter of AncestryChanged to determine what the new parent of the coin is.

2 Likes