In my new game, I was trying to make a gun that would face your mouse cursor, but it keeps returning the error stated in the title despite mouse.Hit.Position being a Vector3. (Before anyone asks, Position and p are both valid.)
My serverside is
local Facing = script.Parent local CenterBrick = game.Workspace:WaitForChild("MamiMusket").Centeral Facing.OnServerEvent:Connect(function(mouseHit) CenterBrick.CFrame = CFrame.new(CenterBrick.Position, mouseHit) end)
and my clientside is
local LP = game.Players.LocalPlayer local mouse = LP:GetMouse() local remote = game.Workspace.MamiMusket.Center.Facing`` while wait() do remote:FireServer(Vector3.new(mouse.Hit.Position)) end
My serverside script shares the parent with the remoteEvent while my clientside is parented to starterGui. I know that, that will be a terrible solution with multiple people but i am only currently trying to get the guns to function at all before I can improve upon their functionality.
Any help would be appreciated,
Thanks!
Edit: I do not need to hold the gun, I want it to orbit around me. Meaning that the problem cannot be solved by simply using my lookVector instead.
this how I make my gun face cursor, (yeah, I hate those gun shoot out 360 degrees too). you cannot just point your gun to the mouse, because you hand is welded to the weapon, if you turn the gun, either the motor6D will break, or the hand is just looking weird.
so what you need to do, is turning humanoidRootPart to the mouse.hit
local character = player.character if character then local direction = Vector3.new(mouse.Hit.p.X, character.HumanoidRootPart.Position.Y, mouse.Hit.p.Z) if character:FindFirstChild("HumanoidRootPart") then character.HumanoidRootPart.CFrame = CFrame.new(character.HumanoidRootPart.Position, direction) else character.Torso.CFrame = CFrame.new(character.Torso.Position, direction) end end
I forgot to add player as the first argument, consider this question, closed.