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

Why am I receiving "Unable to cast to Dictionary" error when attempting to tween a parts position?

I am trying to create a door that, when activated with a Proximity Prompt, will tween the part's position to try to the door visually swing open.

I believe I am typing the code right, yet whenever I hit Play and activate the Proximity Prompt, I get the error message: "Unable to cast to Dictionary"

Any idea what I could be doing wrong? Here is the code:

local TweenService = game:GetService("TweenService")
local door = workspace.Door

script.Parent.Triggered:Connect(function()
	print("Open")
	local tweenInfo = TweenInfo.new(
		2,
		Enum.EasingStyle.Linear,
		Enum.EasingDirection.In
	)
	local goalPos = Vector3.new(-11.45, 3, -2.2)
	local tween = TweenService:Create(door, tweenInfo, goalPos)
end)

2 answers

✓ Accepted answer

Try this tweenservice script

local tweenSerivce = game:GetService(¨TweenService¨)
local tweenInfo = TweenInfo.new(
	2,
	Enum.EasingStyle.Linear,
	Enum.EasingDirection.In,
	0,
	false,
	0
)

local partProperies = {
	Position = Vector3.new(The position of your door)
}

script.Parent.Detector.Touched:Connect(function(hit)
	local tween = TweenService:Create(script.Parent.Door, tweenInfo, partProperties)
	tween:Play()
end

2 comments

0

It worked! Thanks so much!

0

Np

change the goalPos variable to a table containing the position

otherwise, right above the tween:

goalPos = { goalPos }

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