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

Why do I get a 'TweenInfo.new first argument expects a number for time.' error?

Asked by 4 years ago
local ts = game:GetService("TweenService")
local part = script.Parent

local ti  = TweenInfo.new{  

    6, --Length
    Enum.EasingStyle.Elastic, --Easing style 
    Enum.EasingDirection.In, --easing style direction
    2, --Amount of times the tween will repeat
    true, --If the tween will repeat
    3 --Delay between the tweens
}

local partprop = {
    Size = Vector3.new(25,25,25);
}

local tween = ts:Create(part,ti ,partprop)

game.Workspace.Controller.ClickDetector.MouseClick:Connect(function(ChangePos)
    tween:play()
end)



Error: TweenInfo.new first argument expects a number for time.

For some reason, I get that error and can't really see what I did wrong not sure if I'm blind or not

2 answers

Log in to vote
0
Answered by
megukoo 877 Moderation Voter
4 years ago

The error is coming from an unintended side effect of the language I assume you aren't aware about. You don't actually need parentheses to pass an argument to a function:

print"magic!"

And in your case, the argument you're passing to TweenInfo.new is a table:

TweenInfo.new{
    ...
}

-- That's the same as doing this, which is incorrect!
TweenInfo.new({...})

You'll need to replace those curly brackets {} with parentheses () to correctly pass your arguments.

Ad
Log in to vote
0
Answered by
zane21225 243 Moderation Voter
4 years ago

The only error I see here is that you put curly brackets instead of normal parenthesis.

You can see in this DevForum post that parenthesis are required.

Answer this question