"Unable to cast to Dictionary" Error in Tweening a part

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve?
    I want when I press E aiming for the part it floats like telekinesis power

  2. What is the issue?
    Unable to cast to Dictionary error
    image

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I’ve tried seeing youtube tutorials and anothers posts on devforum but didnt find any post similar to my problem

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local UIS = game:GetService("UserInputService")
local TweenA = game:GetService("TweenService")
local euhd = mouse.Target



	
	
UIS.InputBegan:Connect(function(input, gpe)
	
	if input.UserInputType == Enum.UserInputType.Keyboard then
		
		if input.KeyCode == Enum.KeyCode.E and mouse.Target:IsA("BasePart") and mouse.Target.Name ~= "Baseplate" then
			local brhu = mouse.Target
			
			
			
			local goal = {
Vector3.new(brhu.Position.X,euhd.Position.Y+8, euhd.Position.Z)}
			
			
			
local info = TweenInfo.new(
	2,
	Enum.EasingStyle.Linear,
	Enum.EasingDirection.Out,
	0,
	false
			)
			
			local yee = TweenA:Create(brhu, info, goal)
			yee:Play()
		end
	end
end)

Thanks

1 Like

Hello,

There is 2 ways your current code can error.

  • the “brhu” can be nil if mouse.Target doesn’t return anything. Make sure to add a check for that.
  • the “goal” variable is formatted wrong. If you’d like to tween the position, write it like so:
    local goal = {position = Vector3.new()}

Lastly I recommend you rename some variables and fix your indenting for future questions. It makes it somewhat for us to understand/read.

Thanks

1 Like