Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

(not answered)Im trying to make a kill brick for the hostiles, help me please?

Asked by 10 years ago

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)

2 answers

Log in to vote
0
Answered by 10 years ago
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

0
there is issue with line 7 about end <'eof'> dluckey20 25 — 10y
0
oh yeah add an extra end to for the function onTouch threatboy101 2 — 10y
Ad
Log in to vote
0
Answered by 8 years ago
Edited 8 years ago

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)

Answer this question