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
 

Convert Hit to Click

Previous Thread :: Next Thread 
PvN is not online. PvN
Joined: 10 Apr 2010
Total Posts: 22145
31 Jan 2013 10:46 AM
script.Parent.Touched:connect(function (hit)
if hit.Parent and hit.Parent:FindFirstChild("Humanoid") and not script.Parent:FindFirstChild(hit.Parent.Name) then
local user = game.Players:GetPlayerFromCharacter(hit.Parent)
--M.Text = hit.Parent.Name .. " "
M.Name = hit.Parent.Name
game:GetService("Debris"):AddItem(M,5)
end
end)

I don't know how to make it so when you click the brick this stuff happens instead of hitting the brick. My attempts did nothing.
Report Abuse
digpoe is not online. digpoe
Joined: 02 Nov 2008
Total Posts: 9092
31 Jan 2013 11:10 AM
You need a clickDetector, and instead of using the .Touched method/function, use this:

script.Parent.ClickDetector.MouseClick:connect
Report Abuse
lokkut is not online. lokkut
Joined: 18 Mar 2009
Total Posts: 1794
31 Jan 2013 11:11 AM
You need a Click Detector inside of script.Parent, and the connection would be script.Parent.Clicked
Report Abuse
lokkut is not online. lokkut
Joined: 18 Mar 2009
Total Posts: 1794
31 Jan 2013 11:12 AM
Oh yeh, woops. It be confusing after learning some JavaScript and coming back to Lua.
Report Abuse
PvN is not online. PvN
Joined: 10 Apr 2010
Total Posts: 22145
31 Jan 2013 12:01 PM
script.Parent.ClickDetector.MouseClick:connect(function (Clicked)
if Clicked.Parent and Clicked.Parent:FindFirstChild("Humanoid") and not script.Parent:FindFirstChild(Clicked.Parent.Name) then
(also clickdetector in the block)

No errors, but when I click it nothing happens. :\
Report Abuse
digpoe is not online. digpoe
Joined: 02 Nov 2008
Total Posts: 9092
31 Jan 2013 12:03 PM
M isn't defined. I should have read earlier.
Report Abuse
PvN is not online. PvN
Joined: 10 Apr 2010
Total Posts: 22145
31 Jan 2013 12:08 PM
I cut a lot of the script out.
Report Abuse
digpoe is not online. digpoe
Joined: 02 Nov 2008
Total Posts: 9092
31 Jan 2013 12:10 PM
I belive when you do game.Debris:AddItem(instance, timeout) the instance is parented to Debris and the variable is set to nil after timeout. Not sure though, I don't work with Debris often.
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