it doesn’t work
hitpart is unknown
Of course it is, use your own name (hit).
Replace hitpart with hit, it should work after that
You should try to understand the code, if you don’t understand what something does then ask.
oh ok, should i remove this code?
local function FindHumanoid(hit)
local part = hit.Parent
if part:FindFirstChild("npchum") then
return part:FindFirstChild("npchum")
elseif part.Parent:FindFirstChild("npchum") then
return part.Parent:FindFirstChild("npchum")
end
end
Actually yes the function is not needed but may make an error if you use it, you can just put the contents of the function into the script
Yes, the method I’ve used basically checks if the character is controlled by a player.
However if you want to make some characters not get hit then you can simply add a value into them and along my player check add an “or” along.
if player or Character:FindFirstChild(yourvalue) then return end
only if you need to do that, if all non player characters should be hit then you only need the player check.
Wave.Touched:Connect(function(hit)
if hit:IsA("BasePart") then
print("Wave was touched")
if not hit:IsDescendantOf(game.Workspace.Mobs.NPC) then
local EHum = hit.Parent:FindFirstChild("npchum")
if EHum then
print("Has a humanoid")
local debounce = Instance.new("BoolValue", EHum)
debounce.Name = "Debounce"
Debris:AddItem(debounce,.75)
EHum:TakeDamage(Damage)
end
end
end
end)
Maybe we should add prints to see where the script stops working
The script should stop working when there’s an error, which can be seen from the output.
What’s the error or warning that it says in the output?
doesnt do anything and no errors in output
Have you tried using the code I sent with the prints?
yes, but it didn’t print
Wave.Touched:Connect(function(hit)
print("Wave was touched1")
if hit:IsA("BasePart") then
print("Wave was touched2")
if not hit:IsDescendantOf(game.Workspace.Mobs.NPC) then
local EHum = hit.Parent:FindFirstChild("npchum")
if EHum then
print("Has a humanoid")
local debounce = Instance.new("BoolValue", EHum)
debounce.Name = "Debounce"
Debris:AddItem(debounce,.75)
EHum:TakeDamage(Damage)
end
end
end
end)
try this I added another print
alright so it only printed the first 2 not the third
Could you send a screenshot of the objects in the workspace in the explorer?
Wave.Touched:Connect(function(hit)
print("Wave was touched1")
if hit:IsA("BasePart") then
print("Wave was touched2")
if hit.Parent:FindFirstChild("npchum") then
local EHum = hit.Parent:FindFirstChild("npchum")
if EHum then
print("Has a humanoid")
local debounce = Instance.new("BoolValue", EHum)
debounce.Name = "Debounce"
Debris:AddItem(debounce,.75)
EHum:TakeDamage(Damage)
end
end
end
end)
This might work
YES, it works thanks