I'm currently trying to make a projectile system that fires out of the players tool.

Problem 1)

After tool has been equipped first time, the input service is running every time even if the tool isn't even equipped; causing the remote event to fire each time (when it shouldn't).

Problem 2)

The output isn't displaying the players mouse position each time the client sends a request to the server..

Any ideas?

Local


script.Parent.Equipped:Connect(function()
local UserInputService = game:GetService("UserInputService")
local mouse = game.Players.LocalPlayer:GetMouse()
local function onInputEnded(inputObject, gameProcessedEvent)
  if gameProcessedEvent then return end
  if inputObject.KeyCode == Enum.KeyCode.F then
    local position = mouse.Hit.p
    game.ReplicatedStorage.RE.Spell:FireServer(mouse.Hit.p)
  end
end
UserInputService.InputEnded:Connect(onInputEnded)

end)


Server:

game.ReplicatedStorage.RE.Spell.OnServerEvent:Connect(function(player, MouseLocation)
print( string.format("player: '%s', just pressed F!", player.Name) )
print(MouseLocation)
end)

Thank you!