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 » Scripting Helpers
Home Search
 

Re: on touch part function help

Previous Thread :: Next Thread 
johnville is not online. johnville
Joined: 12 Oct 2008
Total Posts: 388
08 Nov 2014 03:55 PM
ok so i have this script ...



db=0

function onTouched(hit)
if hit~=nil then
if hit.Parent~=nil then
if hit.Parent:findFirstChild("Humanoid")~=nil then
if game.Players:findFirstChild(hit.Parent.Name)~=nil then
if db==0 then
db=1
c=hit.Parent:GetChildren()
for i = 1, #c do
if c[i].className=="Tool" then
if c[i]:findFirstChild("Battery")~=nil then
c[i]:findFirstChild("Battery").Value=100
end
end
end
wait(0.5)
db=0
end
end
end
end
end
end)


and it suppose to recharge my battery from my tool to 100 but it doesnt work. i added the script inside the part "MASK" if the MASK is touched u get 100 battery.
I want the script to be inside the part not outisde.
Report Abuse
SenseiWarrior is not online. SenseiWarrior
Joined: 09 Apr 2011
Total Posts: 12140
08 Nov 2014 03:56 PM
You forgot the .Touched event
Report Abuse
Accomplishable is not online. Accomplishable
Joined: 13 Aug 2009
Total Posts: 6207
08 Nov 2014 03:58 PM
part.Touched:connector(onTouched)
Report Abuse
johnville is not online. johnville
Joined: 12 Oct 2008
Total Posts: 388
08 Nov 2014 04:03 PM
the script doesnt look wrong ive tried that and it didnt work.


this was how the script was at first b4 i wanted it to go inside the part




db=0

script.Parent.MASK.Touched:connect(function(hit)
if hit~=nil then
if hit.Parent~=nil then
if hit.Parent:findFirstChild("Humanoid")~=nil then
if game.Players:findFirstChild(hit.Parent.Name)~=nil then
if db==0 then
db=1
c=hit.Parent:GetChildren()
for i = 1, #c do
if c[i].className=="Tool" then
if c[i]:findFirstChild("Battery")~=nil then
c[i]:findFirstChild("Battery").Value=100
end
end
end
wait(0.5)
db=0
end
end
end
end
end
end)





i want to make it to where it works inside the mask part
Report Abuse
AhtnamasStudio is not online. AhtnamasStudio
Joined: 15 Jan 2014
Total Posts: 1104
08 Nov 2014 04:04 PM
function onTouched(hit) you need to complete it at the bottom
How ever I like to do the functions like this
script.Parent.Touched:connect(function(hit)
Report Abuse
AhtnamasStudio is not online. AhtnamasStudio
Joined: 15 Jan 2014
Total Posts: 1104
08 Nov 2014 04:05 PM
Sorry you posted when i was typing mine :P
Whats the error
Report Abuse
johnville is not online. johnville
Joined: 12 Oct 2008
Total Posts: 388
08 Nov 2014 04:16 PM
i want the script to work inside the part.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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