Im using a module script which is being required from a local script,
im trying to make a sword but mouse.Target is nil?
function Sword:Attack()
print("1")
local LocalPlayer = Players.LocalPlayer
local Mouse = LocalPlayer:GetMouse()
local ClosestPlayer = FindClosestPlayer()
if ClosestPlayer then
print("RAN 2 --------------------------")
if LocalPlayer.Character.Humanoid.Health <= 0 then
else
print("RAN 2 --------------------------")
print(Mouse.Target)
if Mouse.Target then
print("RAN 2 --------------------------")
i was debugging it with prints to see which part of my script wasn’t working
i was aiming on the player and it was printing nil
Yeah, this. If what you’re saying is that you’re trying to click on your own player, Mouse.Target and other derivatives like Mouse.Hit ignore the player character. As suggested, you could use a raycast instead to draw a ray from the Camera’s position to Mouse.Hit and then return the raycast’s intercepted object.