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: Functions?

Previous Thread :: Next Thread 
BloxianBuildingTeam is not online. BloxianBuildingTeam
Joined: 20 Apr 2013
Total Posts: 2137
27 Dec 2013 10:23 AM
Well, so I figured out a little bit more about functions in that you can also tie them to an event for a function to happen when an event is fired, and from that I was able to figure out how to make something happen when a part is touched.

However, I still need to know how to identify the player/object that is touching the part. From the identification I can gather how to kill the player (removing the torso), and a few more things I need to do.

But I'm still stuck on how to figure out who touched the part. can somebody help me out?
Report Abuse
Orced is not online. Orced
Joined: 08 Apr 2010
Total Posts: 1301
27 Dec 2013 10:34 AM
function touch(hit) -- hit is a variable of what has touched your brick
check = hit.Parent:FindFirstChild('Humanoid')
if check then
char = check.Parent -- character in workspace
player = game.Players:FindFirstChild(char.Name) -- player (Backpack, PlayerGui)
if char and player then -- to make sure 100%

char.Torso:remove()
end -- check end
end -- final check end
end -- function end
script.Parent.Touched:connect(touch) -- what has to be touched
Report Abuse
kingbowler1040 is not online. kingbowler1040
Joined: 03 Oct 2011
Total Posts: 1202
27 Dec 2013 10:34 AM
I think you were the one who nicely commented my game..

function onTouched(hit)
hit.Parent:FindFirstChild("Humanoid") Like this? Hit in the (), hit.Parent:FindFirstChild("Item") or... clone something to hit.Parent

hit.Parent is the player.
Report Abuse
Orced is not online. Orced
Joined: 08 Apr 2010
Total Posts: 1301
27 Dec 2013 10:36 AM
Your way may glitch. For Ex. if a sword has touched the brick, most likely the script will crash
Report Abuse
kingbowler1040 is not online. kingbowler1040
Joined: 03 Oct 2011
Total Posts: 1202
27 Dec 2013 10:40 AM
Good point, something like...

if hit.Parent:FindFirstChild("Humanoid") then

Report Abuse
Orced is not online. Orced
Joined: 08 Apr 2010
Total Posts: 1301
27 Dec 2013 10:59 AM
Yeah, but it's more advanced to use variables.
Report Abuse
kingbowler1040 is not online. kingbowler1040
Joined: 03 Oct 2011
Total Posts: 1202
27 Dec 2013 12:36 PM
human = hit.Parent:FindFirstChild("Humanoid")
if human then


??
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