guys i want to script a zombie to kill people and I have an error that make it doesnt damage players please help me there is the script:
local rarm = script.Parent:FindFirstChild("Right Arm") local larm = script.Parent:FindFirstChild("Left Arm") function dmg(hit) if hit.Parent ~= nil then local hum = hit.Parent:findFirstChild("Humanoid") if hum ~= nil then hum.Health = hum.Health -10 end end end rarm.Touched:connect(dmg) larm.Touched:connect(dmg)
You have created a function that requires a parameter, but you are calling it without giving it the required parameter.
Try this:
local rarm = script.Parent:FindFirstChild("Right Arm") local larm = script.Parent:FindFirstChild("Left Arm") rarm.Touched:connect(function(Hit) -- So I can get the parameter(Hit) if hit.Parent ~= nil then local hum = hit.Parent:findFirstChild("Humanoid") if hum ~= nil then hum.Health = hum.Health -10 end end end) larm.Touched:connect(function(Hit) -- So I can get the parameter(Hit) if hit.Parent ~= nil then local hum = hit.Parent:findFirstChild("Humanoid") if hum ~= nil then hum.Health = hum.Health -10 end end end)
local rarm = script.Parent:WaitForChild("Right Arm") -- WaitForChild is waiting for that object until its loaded, you problem was that "rarm" or "larm" doesnt exist local larm = script.Parent:WaitForChild("Left Arm") function dmg(hit) if hit.Parent ~= nil then local hum = hit.Parent:findFirstChild("Humanoid") if hum ~= nil then hum.Health = hum.Health -10 end end end rarm.Touched:connect(dmg) larm.Touched:connect(dmg)