Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Help with countdown script?

ERROR : Unable to cast token

WHAT DOES THAT ERROR MEAN?!?!!?!?!

Instance_CMD('Countdown',1,function(Plr,Msg)
coroutine.wrap(function()
for _,v in pairs(game.Players:GetPlayers()) do
local Gui=Instance.new('ScreenGui',v)
local Fm=Instance.new('Frame',v)
Fm.Size=UDim2.new(1,0,0.1,0)
Fm.Position=UDim2.new(0,0,-0.1,0)
Fm.Style='DropShadow'
Fm:TweenPosition(UDim2.new(0,0,0,0),3,4,7)
local Tx=Instance.new('TextLabel',Fm)
Tx.BackgroundTransparency=1
Tx.Size=UDim2.new(1,0,1,0)
Tx.Font='ArialBold'
Tx.FontSize='Size24'
Tx.TextColor3=Color3.new(85/255/0)
Tx.TextStokeTransparency=0
for i = tonumber(Msg),0,1 do -- I believe this is the error line... 
wait(1)
Tx.Text='Countdown [ '..i..' ]'
if i==0 then
Gui:remove()
break
end
end
end
end)()
end)

3 comments

1

Try and negate the third number of that for loop, since you're counting down.

0

So it must be -1 but what does the error mean?!?!!

0

I have made like 3 admin scripts ( Counting out this one ) And I have NEVER seen this error.. I think Im gonna ask UristMcspaks or EinstienK.. But thank you both for the help!

1 answer

✓ Accepted answer

I suggest, like Redbullusa said, to make the third argument in the for loop on line 17 a negative integer. Because you're counting down then you're going to need to go in increments of a negative value.

As a second suggestion, just to make sure we're only getting numbers for arguments in the for loop, use string.match() with %d+, the operater for numbers, as the matching argument.

Example;

for i = tonumber(Msg:match("%d+")),0,-1 do
	--code
end

And I have no idea what that error means, so I can't help you there..

This discussion is preserved as it was. New answers, comments, and votes are closed.