Lua keeps saying unexpected error "=" or it not a correct statement "then"," if" This is my script:
function onTouch(part) local human = part.Parent:findFirstChild("Humanoid") if game.teams.Hostile = true then(human == nil) then return end human.Health = 0 end script.Parent.Touched:connect(onTouch)
function onTouch(part) local human=part.Parent:findFirstChild("Humanoid")if game.teams.Hostile==true and human ~=nil then human:Destroy() end script.Parent.Touched:connect(onTouch)
get rid of the then and the == sign always goes between the if and the then example:if 1+1==2then
and you can also use human==nil instead of human :Destroy() works both ways
this script is basically saying if the team is hostile and the human is there then kill the human when the part is touched
Hey Pal, this should work!
function onTouched(part) local h = part.Parent:findFirstChild("Humanoid") if h~= nil then wait (0.001) h.Health = 0 end end script.Parent.Touched:connect(onTouched)