Hello everyone, I am a beginner scripter and i have some issues with a lava block script, here is the reason: block keeps killing me if its invisible, here is the script:
function onTouched(hit)
local h = hit.Parent:findFirstChild("Humanoid")
if h ~= nil then
h.Health = 0
end end script.Parent.Touched:connect(onTouched)
Do someone have any suggestion to fix this ??
Try this:
1 | function onTouched(hit) |
2 | if script.Parent.CanCollide ~ = false then -- here |
3 | local h = hit.Parent:findFirstChild( "Humanoid" ) |
4 | if h ~ = nil then h.Health = 0 |
5 | end end end |
6 | script.Parent.Touched:connect(onTouched) |
The script is looking if the block can colide where i put this "-- here" if it does not collide it wont go any further. Let me know if it works.