im have a script that spawns characters and stuff… i want the model the get tweened afterwards. I use a event for this and also the values are included in the event
script.EnemySpawn.Event:Connect(function(enemyType, startPos, endPos, tweenTime)
local TI = TweenInfo.new(tweenTime,Enum.EasingStyle.Cubic,Enum.EasingDirection.InOut,0,false,0)
print("Spawning...")
local enemy
if enemyType == "Guitarist" then
print(enemyType, " Spawned!")
enemy = enemyFolder.Guitarist:Clone()
enemy.Parent = workspace.Enemies
local rotation = enemy:GetPivot().Rotation
enemy:PivotTo(startPos*rotation)
TweenService:Create(enemy.HumanoidRootPart,TI,{Position = endPos}):Play()
elseif enemyType == "StoneStatue" then...
the script goes one like this howewer i keep getting this error
TweenInfo.new first argument expects a number for time.
i get this error intead Players.Ghostisnothere2098.PlayerGui.enemySpawns:13: attempt to index number with 'Value'
edit: i printed out the tweenTime and i just gets printed out as “3” i dont understand what is wrong here
another edit: it also occasionally gets printed as nil…
Is it because tweenTime is typed as a string? Try doing this:
local TI = TweenInfo.new(tonumber(tweenTime),Enum.EasingStyle.Cubic,Enum.EasingDirection.InOut,0,false,0)
Edit: Just saw that you mentioned:
Blockquote
another edit: it also occasionally gets printed as nil…
This may be a much deeper rooted issue related to other parts of your code then, the code provided above is not enough for us to debug it for you. Consider going through the code yourself (Or posting more relevant parts of it, so we can have a better understanding) and refactoring some parts of it.
That’s odd, clearly tweenTime is indeed a number.
For debugging purposes, print every argument from the event and see what they are. Maybe they aren’t always what you expect them to be?
your line of code magically worked…
i have no idea what was the issue, some roblox jank maybe?
also thank you very much ive been trying to solve this for 3 days