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: OnTouched

Previous Thread :: Next Thread 
trogyssy is not online. trogyssy
Joined: 29 Oct 2010
Total Posts: 2322
01 Mar 2014 05:03 PM
Would a function called when a part is touched work if the part being touched has a mesh?
Report Abuse
Azureous is not online. Azureous
Joined: 29 Jan 2012
Total Posts: 25287
01 Mar 2014 05:04 PM
Yes it should still work.
Report Abuse
trogyssy is not online. trogyssy
Joined: 29 Oct 2010
Total Posts: 2322
01 Mar 2014 05:05 PM
Thank you :)
Report Abuse
Goulstem is not online. Goulstem
Joined: 04 Jul 2012
Total Posts: 7177
01 Mar 2014 05:07 PM
Yes. It doesn't matter, just don't make the Event go off of the mesh like a moron then you're fine lol.
Report Abuse
trogyssy is not online. trogyssy
Joined: 29 Oct 2010
Total Posts: 2322
01 Mar 2014 05:16 PM
Yeah ik that -_-

Didn't work though. Here's the script. "Clip" is a NumberValue under the player

function Reload(hit)
if hit:FindFirstChild("Humanoid")then
local Player=Game.Players:FindFirstChild(hit.Name)
if Player then
if Player.TeamColor==script.Parent.BrickColor then
hit.Humanoid.Health=hit.Humanoid.MaxHealth
if Player:FindFirstChild("Clip")then
Player.Clip.Value=40
end
end
end
end
end
script.Parent.Touched:connect(Reload)
Report Abuse
trogyssy is not online. trogyssy
Joined: 29 Oct 2010
Total Posts: 2322
01 Mar 2014 05:33 PM
bump
Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
01 Mar 2014 05:34 PM
Oh gawd..
Its not hit:findFirstChild
Its hit.Parent:findFirstChild..
Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
01 Mar 2014 05:35 PM
Also
FindFirstChild(hit.Parent.Name)
Dude,u forgot the parent in like every line
Report Abuse
trogyssy is not online. trogyssy
Joined: 29 Oct 2010
Total Posts: 2322
01 Mar 2014 05:38 PM
Revised, still don't work:

function Reload(hit)
local thing hit.Parent:FindFirstChild("Humanoid")
if thing then
local Player=Game.Players:FindFirstChild(thing.Parent.Parent.Name)
if Player then
if Player.TeamColor==script.Parent.BrickColor then
hit.Parent.Humanoid.Health=hit.Humanoid.MaxHealth
if Player:FindFirstChild("Clip")then
Player.Clip.Value=40
end
end
end
end
end
script.Parent.Touched:connect(Reload)

no errors in output...
Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
01 Mar 2014 05:42 PM
Well,your close at least:

function Reload(hit)
local thing = hit.Parent:FindFirstChild("Humanoid")
if thing then
local Player=game.Players:FindFirstChild(hit.Parent.Name)
if Player then
if Player.TeamColor==script.Parent.BrickColor then hit.Parent.Humanoid.Health=hit.Parent.Humanoid.MaxHealth
if Player:FindFirstChild("Clip") then
Player.Clip.Value=40
end
end
end
end
end
script.Parent.Touched:connect(Reload)
Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
01 Mar 2014 05:43 PM
What I posted should work
Report Abuse
trogyssy is not online. trogyssy
Joined: 29 Oct 2010
Total Posts: 2322
01 Mar 2014 08:01 PM
Thank you, works like a charm :)
Report Abuse
Goulstem is not online. Goulstem
Joined: 04 Jul 2012
Total Posts: 7177
01 Mar 2014 09:42 PM
script.Parent.Touched:connect(function(hit)
if hit:FindFirstChild("Humanoid") then
local Player = game.Players:FindFirstChild(hit.Name)
if (Player ~= nil) then
if Player.TeamColor == --Just put the BrickColor. then
hit.Parent.Humanoid.Health = 99999
if Player:FindFirstChild("Clip")then
Player.Clip.Value = 40
end end end end end)
Report Abuse
Goulstem is not online. Goulstem
Joined: 04 Jul 2012
Total Posts: 7177
01 Mar 2014 09:44 PM
Sorry typo.

script.Parent.Touched:connect(function(hit)
if hit:FindFirstChild("Humanoid") ~= nil then
local Player = game.Players:FindFirstChild(hit.Parent)
if (Player ~= nil) then
if Player.TeamColor == --(Just put the BrickColor.) then
hit.Parent.Humanoid.Health = 99999
if Player:FindFirstChild("Clip")then
Player.Clip.Value = 40
end end end end end)
Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
01 Mar 2014 09:45 PM
@Goul
I already answered lul
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