(SOLVED) Unable to cast to Dictionary error

I am currently making a simple raycasting gun but I keep getting this error “Unable to cast to Dictionary” on line 21


local TweenService = game:GetService("TweenService")

script.Parent.OnShoot.OnServerEvent:Connect(function(player, pos)
	local Position = script.Parent.Shoot.Position
	local Direction = (pos - Position).Unit
	local rcParams = RaycastParams.new()
	rcParams.FilterDescendantsInstances = {script.Parent} 
	rcParams.FilterType = Enum.RaycastFilterType.Blacklist
	local ray = workspace:Raycast(Position, Direction * 300, rcParams)

if ray then
	

local bullet = game:GetService("ServerStorage").Bullet:Clone()
bullet.Parent = game.Workspace
bullet.CFrame = script.Parent.Shoot.CFrame

	print(ray.Position)
	
	local tweenInfo = TweenInfo.new(1)
	local tween = TweenService:Create(bullet, tweenInfo, ray.Position)

	tween:Play()
	
end
end)

line 21 (the line with the error) is this line:

local tween = TweenService:Create(bullet, tweenInfo, ray.Position)
1 Like

TweenService:Create(Instance, TweenInfo, Properties) takes 3 parameters. You have the first two correct, but the third one should be a dictionary where the keys reference the properties of the first parameter, Instance, that you want to tween.

TweenService:Create(bullet, tweenInfo, { Position = ray.Position })
1 Like

Check out the documentation for more info: TweenService | Documentation - Roblox Creator Hub

That worked! I don’t completely understand how it worked but i’m going to figure it out

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.