Im trying to make a death brick but when I step on it nothing happens, here's the code:
local lava = game.Workspace.Lava fuction OnTouch(Lava) local human = lava.parent:FindFirstChild("Humanoid") if human ~= nil then human.MaxHealth = 0 end end script.parent.touched:Connect(function(Ontouch))
and could someone also explain to me why there needs to be two ends?
It is not working for a couple reasons, you wrote "fuction" instead of function. Also on your last line you only have to say "script.Parent.Touched:Connect(OnTouch)" Because you are calling a function instead of running an argument. Lastly Lua is case sensitive so "script.parent" has to be "script.Parent". So your code would be:
local lava = game.Workspace.Lava function OnTouch(Lava) local human = lava.Parent:FindFirstChild("Humanoid") if human ~= nil then human.Health = 0 end end script.Parent.Touched:Connect(OnTouch)
first of all you have a few mistakes here and there you writed fuction instead fo function and you missed some capitales. There needs to be 2 end to close functions at line 2 and a normal end
local lava = game.Workspace.Lava fuction OnTouch(Lava) local human = lava.Parent:FindFirstChild("Humanoid") if human ~= nil then human.Health = 0 end end) script.Parent.Touched:Connect(function(Ontouch))
hope this helps