Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Help with countdown script?

Asked by 9 years ago

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)
1
Try and negate the third number of that for loop, since you're counting down. Redbullusa 1580 — 9y
0
So it must be -1 but what does the error mean?!?!! MessorAdmin 598 — 9y
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! MessorAdmin 598 — 9y

1 answer

Log in to vote
1
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
9 years ago

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..

Ad

Answer this question