|
| 01 Nov 2016 11:12 AM |
so i made a drawning script bu it dont works.
the idea is to check all the childeren in of the parent thats touch and if the head touchs it then the script needs to run. it but i think i do it wrong here is my script please help.
------------------------------- function onTouched(part) local h = part.Parent:GetChildren() if h == "Head" then h.Health = h.Health -5 wait(2) end end
script.Parent.Touched:connect(onTouched) |
|
|
| Report Abuse |
|
|
|
| 01 Nov 2016 11:25 AM |
One Piece much >_>
local DamageAmount = 5 local Touched = false
script.Parent.Touched:connect(function(hit) if Touched then return end Touched = true local Humanoid = hit.Parent:FindFirstChild("Humanoid") if Humanoid then Humanoid.Health = Humanoid.Health - DamageAmount wait(1) end Touched = false end)
R$12,714 -- <_< well then <_< |
|
|
| Report Abuse |
|
|
|
| 01 Nov 2016 11:32 AM |
| o i want that when u hit it it does nothing but if you touch it with your head it wil kill you |
|
|
| Report Abuse |
|
|
qqtt991
|
  |
| Joined: 14 Dec 2007 |
| Total Posts: 1387 |
|
|
| 01 Nov 2016 12:18 PM |
Yikes lol. If I've done this right, it should drain your health for as long as your head is touching the brick, but stop if your head stops touching the brick.
local function drainHealth(humanoid) while humanoid.Health > 0 do humanoid.Health = humanoid.Health - 10 wait(0.5) script.Parent.TouchEnded:Connect(function() script.Disabled = true; wait(); script.Disabled = false end) end end
local function onTouched(hit) if hit.Name == "Head" then local humanoid = hit.Parent:FindFirstChild("Humanoid") if humanoid then drainHealth(humanoid) end end end
script.Parent.Touched:Connect(onTouched)
|
|
|
| Report Abuse |
|
|
qqtt991
|
  |
| Joined: 14 Dec 2007 |
| Total Posts: 1387 |
|
|
| 01 Nov 2016 12:24 PM |
Side note: If you want a delay before it starts trying to kill you, I think you can just put a wait(1) or something before the while loop in drainHealth().
|
|
|
| Report Abuse |
|
|