I've been trying to fix this for hours, i'm a beginner at this stuff
LocalScript:
local plr = game:GetService("Players").LocalPlayer local char = plr.Character or plr.CharacterAdded:wait() local mouse = plr:GetMouse() local tool = script.Parent local anim = tool:FindFirstChild("PunchAnimation") local Debounce = true local Damaged = false char:WaitForChild("LeftHand").Touched:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") and not Debounce and not Damaged and hit.Parent.Humanoid ~= plr.Character.Humanoid then if plr.Character.Humanoid.Health > 0 then Damaged = true game:GetService("ReplicatedStorage").RemoteEvents.punch :FireServer(hit.Parent.Humanoid) end end end) tool.Equipped:Connect(function() print("A tool was equipped") mouse.Button1Down:Connect(function() print("Tool clicked") local hum = tool.Parent:FindFirstChild("Humanoid") if hum and Debounce then Debounce = false anim = hum:LoadAnimation(tool.PunchAnimation) anim:Play() wait(0.5) Debounce = true end end) end)
ServerScript:
game:GetService("ReplicatedStorage") .RemoteEvents.punch.OnServerEvent:Connect(function(player, humanoid) if humanoid.Health >= 0 then humanoid.Health = humanoid.Health - 10 elseif humanoid.Health < 0 then humanoid.Health = 0 end end)
You shouldn't be trusting the client with that type of information but, the humanoid you're referring to in the server script is nil
Closed as Non-Descriptive by hiimgoodpack, EmbeddedHorror, and BlackOrange3343
This question has been closed because its title or content does not adequately describe the problem you are trying to solve.
Please ensure that your question pertains to your actual problem, rather than your attempted solution. That is, you were trying to solve problem X, and you thought solution Y would work, but instead of asking about X when you ran into trouble, you asked about Y.
Why was this question closed?