Hello,I was trying to make a simple gun with remote events,but this error is happening to me. "bad argument #2(Vector3 expected,got Object)" on the server script.Anyways,the local script of the gun is this one:
local BulletEvent = game:GetService("ReplicatedStorage"):WaitForChild("BulletShoot")
local Tool = script.Parent
local Player = game.Players.LocalPlayer
Tool.Equipped:Connect(function(mouse)
mouse.Button1Down:Connect(function()
BulletEvent:FireServer(Player,Tool.Handle.Shoot.Position, mouse.Hit.Position)
end)
end)
And for the remote event:
local BulletEvent = game:GetService("ReplicatedStorage"):WaitForChild("BulletShoot")
local RS = game:GetService("ReplicatedStorage")
BulletEvent.OnServerEvent:Connect(function(Player,FromP,ToP)
local castRay = Ray.new(FromP, (ToP - FromP).unit * 100)
local hit,Position = workspace:FindPartOnRay(castRay, Player.Character)
if hit then
local Human = hit.Parent:FindFirstChild("Humanoid")
if Human then
Human:TakeDamage(20)
end
end
local Laser = Instance.new("Part",workspace)
Laser.BrickColor = BrickColor.new("Really red")
Laser.Material = "Neon"
Laser.CanCollide = false
local Dist = (ToP - FromP).magnitude
Laser.CFrame = CFrame.new(FromP, Position)
Laser.Size = CFrame.new(0.1,0.1,Dist) * CFrame.new(0,0,-Dist/2)
game.Debris:AddItem(Laser,0.01)
end)
Tell me if you need other scripts.I would really appreciate if you can solve this problem.(2x)
Thanks.

2 comments
Can you give us the exact error?
The line 6 is not needed,and the line will be deleted.