Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR LUA

Roblox Lua

---how Not to use humanoids correctly-----------------
script.Parent.Touched:Connect(function(otherpart)
	local Humanoid = otherpart:FindFirstChild("Humanoid")
    if Humanoid ~= nil then
    Humanoid.Health = 0
    end
end)
--so lets see whats wrong here
--first the otherpart is touching the hurt brick not the model 
--which means that its telling the part the touched the hurt brick
--to find the child within the foot yeah not going to work 
------------------how to do it correctly-----------------------------------------------------

script.Parent.Touched:Connect(function(otherpart)
	local Humanoid = otherpart.parent:FindFirstChild("Humanoid")
    if Humanoid ~= nil then
    Humanoid.Health = 0
    end
end)
so if you were to make the parent of the part model which has the humanoid in it 
it will find humanoid and hurt the model with the hurt brick
-----------------------how not to use a teleport brick correctly------------------------------------
script.Parent.Touched:Connect(function(otherpart)
local Humanoid = otherpart.parent:FindFirstChild("Humanoid")
if Humanoid ~= nil then
Humanoid.RootPart.Position = Vector3.new(1,35,6)
end
end)
--well  you're not suppposed to use Vector3.new for teleport brick
--but you still can if you really want too use that method anyways 
--here is the correct way to do it
----------------how to use a teleport brick correctly----------------------------------------
script.Parent.Touched:Connect(function(otherpart)
local Humanoid = otherpart.parent:FindFirstChild("Humanoid")
if Humanoid ~= nil then
Humanoid.RootPart.Position = game.workspace.TeleportBrick1.position---or two if you want it to teleport you back on the other brick
end
end)
--thats all i can give you for advice currently
Source by developer.roblox.com #
 
PREVIOUS NEXT
Tagged: #Roblox #Lua
ADD COMMENT
Topic
Name
1+4 =