so i made a gun and uhh everything works except damage.
so in the local script it sends the Mouse.Target.Parent, and when it first failed i made it print the target which it did and it was not nil, then i made it print the humanoid, again not nil.
and then i made it print a message so that i would know if it entered the if statement, which it did.
but it doesn’t damage it.
serverscript;
local Tool = script.Parent
local Connection = Tool:WaitForChild("Connection")
Connection.OnServerEvent:Connect(function(plr,Target)
print("Fired!!")
local PossibleHumanoid = Target:FindFirstChildWhichIsA("Humanoid")
print(Target)--Prints [InsertModelNameHere]
print(PossibleHumanoid)--Prints "Humanoid"
if PossibleHumanoid then
print("Started")--Prints
PossibleHumanoid.Health -= 175--Doesn't Run
end
end)
You should raycast, otherwise when using mouse.Target, it will simply only fire the thing you’re hovering over, so it doesn’t take into account what’s in the line of sight.
But, that’s out of the question, instead of subtracting health, try use PossibleHumanoid:TakeDamage(175), and see what that does. If it still doesn’t work, then see if theres another script changing the health or interfering in some way.
ok so i printed the health before and after the damage should’ve been taken, the first one says “Nil” and the second one doesn’t print. but the humanoid exists because of the print i used to see if there’s a humanoid
edit: i tested it once more and this time it prints 0 both of times while the humanoid has 100 health
ok so i found the problem, it had something to do (idk what though it looked completely fine) with the humanoid, i ended up having to delete and replace it with a new one.
at least i know it wasn’t because of the gun.