I want to make a simple gun system and it gave me this error
18:16:40.159 ServerScriptService.PistolFire:8: attempt to perform arithmetic (sub) on nil and Vector3 - Server - PistolFire:8
I’ve tried making the raycastparams different but I don’t know many options
game.ReplicatedStorage.PistolEvent.OnServerEvent:Connect(function(Player, PlayerMouse, FireTool)
FireTool:WaitForChild("Handle").Fire:Play()
local raycastParams = RaycastParams.new()
raycastParams.FilterDescendantsInstances = {Player.Character}
raycastParams.FilterType = Enum.RaycastFilterType.Blacklist
local raycastResult = workspace:Raycast(FireTool:WaitForChild("Handle").Position, (PlayerMouse - FireTool:WaitForChild("Handle").Position)*300,raycastParams)
if raycastResult then
local Model = PlayerMouse:FindFirstAncestorOfClass("Model")
if Model:WaitForChild("Humanoid") then
Model.Humanoid.Health -= 25
FireTool:WaitForChild("Handle").HitMarker:Play()
PlayerMouse.Icon = "rbxassetid://7193947094"
wait()
PlayerMouse.Icon = "rbxassetid://62814275"
end
end
end)```