I need help doing this. I am gonna make an obby.
You can use the Touched event with a part like so:
part.Touched:connect(function(hit)
And then you can find out if the part belongs to a player like this:
humanoid=hit.Parent:FindFirstChild("Humanoid") if humanoid ~=nil then
And then you can use your favorite method for killing a player, here is mine:
hit.Parent.Torso:Destroy()
And then all together we have this:
part.Tocuehd:connect(function(hit)--Touched event! humanoid=hit.Parent:FindFirstChild("Humanoid")--Finding the Humanoid! if humanoid ~=nil then--If the humanoid exists! hit.Parent.Torso:Destroy()--Killing the player! end end)
Use a script that upon touch humanoid health = 0
In obbies, people like chances, so make it upon touch damage humanoid 30 to 40
You can use this script:
function Touched(hit) humanoid-hit.Parent.findFirstChild("Humanoid") if Humanoid ~=nil then Instance.new("Part, Head") hit.Head:Destroy() end end script.Parent.onTouched:connect(hit)
Hello Allisaurus!
This simple script will kill a player on touch.
The green text explains what each part does.
bin = script.Parent --This is a variable. We can use this later, in the function. function onTouched(Part2) --This is the function. local h = Part2.Parent:FindFirstChild("Humanoid") --We are searching for the player's body here. if h then --If it is there, then.... while h.Health > 0 do --Check if it's health is greater than zero. I'm not sure if this is needed, but I keep it anyway. h.Health = h.Health - 100 --Take away the player's health. wait(1) --Waits a second. Probably not needed either, but whatever. end end end --Ends the function. bin.Touched:connect(onTouched) --This connects the function.
I hope this helps. Good luck with your obby!
script i use is function onTouch(part) local humanoid = part.Parent:FindFirstChild("Humanoid") if (humanoid ~= nil) then -- if a humanoid exists, then humanoid.Health = 0 -- damage the humanoid end end
script.Parent.Touched:connect(onTouch)
It's easy, you would just need a upontouched(), and a function to take the players health down to zero. On free models, there are loads of scripts that do exactly that.