TweenInfo.new first argument expects a number for time

  1. What do you want to achieve?
    I’m trying to make a tweening shift to run script

  2. What is the issue?
    I get this error saying “TweenInfo.new first argument expects a number for time.”

  3. What solutions have you tried so far?
    I looked for solutions and people say that they need to replace brackets with parentheses which is what im using already

Here’s the script:

repeat wait() until game.Players.LocalPlayer
local start = 16
local goal = 32
local TweenService = game:GetService("TweenService")
local speed = game.Players.LocalPlayer.Character.Humanoid.WalkSpeed
local tweeninfo = TweenInfo:new(
	
	2,
	Enum.EasingStyle.Cubic,
	Enum.EasingDirection.Out,
	0,
	false,
	0
	
)

local tween = TweenService:Create(speed, tweeninfo, {speed = goal})
local tweenout = TweenService:Create(speed, tweeninfo, {speed = start})

m = game.Players.LocalPlayer:GetMouse()

m.KeyDown:connect(function(key)
	if key == "304" then
		tween:Play()
		print("Works")
	end
end)

m.KeyUp:connect(function(key)
	if key == "304" then
		tweenout:Play()
		print("Works2")
	end
end)
2 Likes

You wrote TweenInfo:new(…) instead of TweenInfo.new(…).

When you use : the first argument that is given is self (table) instead of a number for the time parameter. When you use . it does not pass the self into the first argument and so the number you’ve selected (2) goes there.

5 Likes

Oh, it got fixed, thanks alot :slight_smile: I’m actually still learning about Tweenservice and i didn’t know what’s the issue, but now i know, thank you!

2 Likes