function onTouch(Part) Instance.new ("Fire", game.Workspace.Part wait(0.00001) Player:findFirstChild("Humanoid").Health = 0 wait(0.00001) game.Workspace.Part.Fire.Enabled = true wait(5) game.Workspace.Part.Fire.Enabled = false end script.Parent.Touched:connect(onTouch)
Im wondering if this would insert a fire into the brick and also kills at the same time when touched.
Part
is your variable name for the part that touches brick
. You have to find the player/character through this part. wait(0.00001)
is such a short time that the thread will yield for one frame anyway, so I'd just say wait(0)
for the shortest amount of time possible if that's what you're going for.local brick = script.Parent function onTouch(Part) -- Declare our function onTouch where 'Part' is the part that touches 'brick' local fire = Instance.new ("Fire", Part) -- Create's fire in the part that touches 'brick' wait(0) -- Waits one frame (extremely short amount of time) local hum = Part.Parent:FindFirstChild("Humanoid") -- looks for a Humanoid in 'Part.Parent' if hum then -- If the Humanoid exists (if a Character has touched 'brick') hum.Health = 0 -- Set the health of that Humanoid to 0 end -- Close 'if' scope wait(5) if fire then -- If after 5 seconds 'fire' still exists, then fire:Destroy() -- Remove the fire end end brick.Touched:connect(onTouch)
Perhaps you should define the player or search if it contains a humanoid.
local brick = script.Parent function onTouch(Part) if Part.Parent:findFirstChild("Humanoid") and Part.Parent.Name == game.Players:FindFirstChild(Part.Parent.Name) then local fire = Instance.new ("Fire", script.Parent) wait(0) Part.Parent:findFirstChild("Humanoid").Health = 0 wait(5) fire:Destroy() end end brick.Touched:connect(onTouch)
@Dummiez
Wouldn't it be wait()
if you want to wait for the shortest time possible?