generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: drowning script help

Previous Thread :: Next Thread 
yentedolfijn is not online. yentedolfijn
Joined: 16 Apr 2014
Total Posts: 276
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
spyspace12 is online. spyspace12
Joined: 16 Nov 2012
Total Posts: 615
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
yentedolfijn is not online. yentedolfijn
Joined: 16 Apr 2014
Total Posts: 276
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 is online. 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 is online. 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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image