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)