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

I get an error when I run my Elevator Tween Script?

I get the error Unable to Cast to Dictionary ( Line 7 ) What am I doing wrong

I'm trying to tween a model btw

local TweenService = game:GetService("TweenService")
local primary = script.Parent.A

local TweenIn = TweenInfo.new(0.5, Enum.EasingStyle.Back,  Enum.EasingDirection.Out)

local tween = TweenService:Create(primary, TweenIn, -89.1, 170.39, 197.95)

game.Workspace.CallElevatorFloor1.ClickDetector.MouseClick:Connect(function()
tween:Play()
end)

1 comment

0

You have mistaken the arguments for :Create(). The proper arguments are TweenService:Create(instance,TweenInfo,propertyTable). Read here for a correct example of Tweening: https://developer.roblox.com/en-us/api-reference/function/TweenService/Create

1 answer

✓ Accepted answer

The error code: Unable to Cast to Dictionary, means the code cannot set a tween to a value which has not been defined

The error you made was on line 6 where I believe you tried to set a tween position.

##Corrected script

local TweenService = game:GetService("TweenService")
local primary = game.Workspace.A
local TweenIn = TweenInfo.new(0.5, Enum.EasingStyle.Back,  Enum.EasingDirection.Out)

local tween = TweenService:Create(primary, TweenIn,{Position = Vector3.new(0, 30, 0)}) -- change to your positions
game.Workspace.CallElevatorFloor1.ClickDetector.MouseClick:Connect(function()
	tween:Play()
end)
print (1)




If you have any enquires feel free to comment.

9 comments

0

Its in a model but nothing happens when i click the button

0

Do you have a video or a snapshot?

0

Does it print , it works for me I've tested it.

0

Am I referencing the model or the primarypart

0

Delete the weld under the part

0

Do I anchor the Primary part and leave the rest unanchored?

0

Unanchor the primary part.

0

Make sure you delete the weld or it won't work

0

Also send a video of which is not working

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