I’m trying to make a V2 of my gun system, however I found this issue. Instead of passing over the mouse hit position to the server it passes the player instance, I am so confused.
Server Script (GunHandler):
game.ReplicatedStorage.GunRemotes.ShootGun.OnServerEvent:Connect(function(mousePos, startpoint, tool, dmg, headdmg, range)
local origin = startpoint
local direction = (startpoint - mousePos).unit * range
local raycastParams = RaycastParams.new()
raycastParams.FilterType = Enum.RaycastFilterType.Blacklist
raycastParams.FilterDescendantsInstances = IgnoreList
raycastParams.IgnoreWater = true
local results = workspace:Raycast(origin, direction, raycastParams)
if results then
print(results)
end
end)
Local script:
mouse.Button1Down:Connect(function()
if available then
if Semi ~= true then
isHeld = true
repeat
for index = 1, Firerate do
local startPos = muzzle.Position
local tool = script.Parent
print(mouse.Hit.Position)
gunRemote.ShootGun:FireServer(game.Players.LocalPlayer:GetMouse().Hit.p, startPos, tool, Damage, headDamage, range)
end
wait(RPM/60)
until isHeld == false or not available
else
end
end
end)
The only error is: “ServerScriptService.GunHandler:15: invalid argument #2 (Vector3 expected, got Instance)”