The goal of this script is when ever a player clicks on a different player, that player will be injured, but when ever i click i get this error attempt to perform arithmetic on field 'Health' (a nil value)
This is a local script
player = game.Players.LocalPlayer
character = game.Players.LocalPlayer.Character
gun = character:findFirstChild("Rifle")
mouse = player:GetMouse()
mouse.Button1Down:connect(function()
function getModel(raw)
for _,__ in next (workspace:GetChildren()) do
if raw:IsDescendantOf(__) then
return __;
end;
end;
return raw;
end;
local success,hum = pcall(function() return getModel(mouse.Target).Humanoid end);
hum.Health = hum.Health -15
end)

2 comments
Overly complicated?
Thank you