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: I need some help with this function onTouch() script.

Previous Thread :: Next Thread 
CrossArmsALT4 is not online. CrossArmsALT4
Joined: 03 Aug 2012
Total Posts: 7889
16 Apr 2013 09:13 AM
I am making a brick, that once stepped on removes a LinkedSword from the humanoid that touches it from the Humanoid's backpack.

This is how far I have been able to go with it:

function onTouch()
    local humanoid = part.Parent:FindFirstChild("Humanoid")
    if (humanoid ~= nil) then --if a humanoid exists
        
                                                      <----- the actual removing part I believe goes here
    
    script.Parent.Touched:connect(onTouch)



Report Abuse
getkoed2 is not online. getkoed2
Joined: 11 Apr 2010
Total Posts: 1144
16 Apr 2013 09:18 AM
Hi!

Just to be clear, this post isn't hostile... If it is, consider the whole world as hostile.

I suggest you take a few free models that do the same as what you want, learn how they work and try to edit some things. If your edited code works, try making it yourself. That is the easiest way to learn how to script.

Good luck!
Report Abuse
SamuelKingx is not online. SamuelKingx
Joined: 27 Jan 2012
Total Posts: 3472
16 Apr 2013 09:23 AM
"Humanoid's backpack"

>First off, the backpack is in the Player, not the Humanoid. Second, do what getkoed said, just learn off of free models by editing them and seeing if they contain stuff that you don't already know and such.

~If you're generous enough: http://www.roblox.com/--item?id=97553537~
Report Abuse
CrossArmsALT4 is not online. CrossArmsALT4
Joined: 03 Aug 2012
Total Posts: 7889
16 Apr 2013 09:59 AM
@getkoed2


There is nothing hostile about your post on this thread in particular, but that really doesn't help me. Just saying "learn to scipt" as a reply to a question on a forum called "Scripting Helpers" isn't all that useful.
Report Abuse
getkoed2 is not online. getkoed2
Joined: 11 Apr 2010
Total Posts: 1144
16 Apr 2013 10:52 AM
Could you please state where I said 'learn to script'?

Thank you!
Report Abuse
ForceSky is not online. ForceSky
Joined: 30 Jul 2012
Total Posts: 2379
16 Apr 2013 03:22 PM
I think you're overreacting. He's just saying the easiest way to learn to script, the way I did it. Here's the script:

function onTouch(hit)
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
if plr ~= nil then
repeat wait() until plr.Backpack.LinkedSword
plr.Backpack.LinkedSword:Destroy()
end
end
end

script.Parent.Touched:connect(onTouch)


If it errors, remove the third end. I'm not sure if repeat needs an end.
Report Abuse
getkoed2 is not online. getkoed2
Joined: 11 Apr 2010
Total Posts: 1144
16 Apr 2013 05:02 PM
No, it doesn't. Basically the line after until is the 'end' of repeat.
Report Abuse
ForceSky is not online. ForceSky
Joined: 30 Jul 2012
Total Posts: 2379
16 Apr 2013 08:13 PM
Ah, ok. The correct script:

function onTouch(hit)
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
if plr ~= nil then
repeat wait() until plr.Backpack.LinkedSword
plr.Backpack.LinkedSword:Destroy()
end
end

script.Parent.Touched:connect(onTouch)
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