I am attempting to create a projectile, and whenever I use the CFrame:LookAt() Command it states that I have an "Invalid argument #1 to ‘lookat’ (vector3 expected, got table) I have checked both my vector3s in the command to make sure that they are actually vector3s, and both are.
Here is my code:
--Local script
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local loop = true
local tool = script.Parent.Parent
local Events = tool.Events
local parts = tool.Parts
local repStorage = game:GetService("ReplicatedStorage")
local rocket = repStorage:WaitForChild("Rocket")
local rocketAvailable = true
local FirePart = parts.FirePart
local FireRocket = Events.FireRocket
local mouse = player:GetMouse()
tool.Activated:Connect(function()
if rocketAvailable == true then
FireRocket:FireServer(rocket, mouse.Hit.Position, FirePart.Position)
end
end)
--Server script
local tool = script.Parent.Parent
local events = tool.Events
local FireRocket = events.FireRocket
FireRocket.OnServerEvent:Connect(function(player, rocket, mouseHit, firePosition)
local rocketClone = rocket:Clone()
rocketClone.Parent = workspace
rocketClone.CFrame = CFrame:lookAt(firePosition, mouseHit)
rocketClone.Script.Disabled = false
end)
I deleted all but the relevant code, and there isn’t much else anyways. Any help is appreciated.
Thanks in advance!