Search
 
SCRIPT & CODE EXAMPLE
 

LUA

How to use Humanoids in 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
Comment

PREVIOUS NEXT
Code Example
Lua :: how to make kill block in roblox lua 
Matlab :: num to string matlab 
Matlab :: matlab how to set figure size so you can see plot 
Matlab :: matlab measure time 
Matlab :: matlab plot vertical line 
Matlab :: how to read dat file in matlab 
Matlab :: if else in matlab 
Matlab :: tan in scilab 
Matlab :: pass variable by reference to function in matlab 
Matlab :: cos in scilab 
Basic :: git access token 
Basic :: the terminal process failed to launch 
Basic :: API Key Authentication, Basic , Pasword Grant, Client Credentials 
Elixir :: elixir try rescue 
Elixir :: elixir read csv file 
Elixir :: create new project phoenix 
Scala :: two dimensional array scala 
Scala :: dataframe column json parser spark scala 
Actionscript :: reset udemy course 
Excel :: google sheets convert abbreviation of month to number 
Excel :: excel and formula 
Perl :: Perl list files and folders in a directory 
Pascal :: exceptions in pascal 
Powershell :: takeown /f 
Gdscript :: godot 3d slowly rotate towards object 
Erlang :: get erlang version 
Assembly :: wget output filename 
Assembly :: flutter button border radius 
Javascript :: jquery vslidation remove spaces from input 
Javascript :: jquery unselect option 
ADD CONTENT
Topic
Content
Source link
Name
9+4 =