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: Hi, please help me fix this minor script.

Previous Thread :: Next Thread 
iamwalker257 is not online. iamwalker257
Joined: 14 Jan 2008
Total Posts: 3820
16 Jan 2012 08:44 AM
enabled = true

function onClicked()
if not enabled then return end
enabled = false
local p = Instance.new("Part")
p.Position = script.Parent.Parent.Drop.Position
p.Size = Vector3.new(2,1,4)
p.Name = "CabbageBrick"
p.Parent = script.Parent.Parent.Parent

script.Parent.ClickDetector:remove()
script.Parent.Transparency = 1
wait(5)
local c = Instance.new("ClickDetector")
c.MaxActivationDistance = 32
c.Parent = script.Parent
script.Parent.Transparency = 0
enabled = true
end

script.Parent.ClickDetector.MouseClick:connect(onClicked)



-------------------------------------------------------------------------------

Ok so this is inside a brick in which when clicked tells another brick to create the "Part". That works fine. But not the second time. It worked before i added things about adding/removing "ClickDetector". The "ClickDetector" gets created correctly but it still does not connect. Any solutions/other ways of doing this?
Report Abuse
iamwalker257 is not online. iamwalker257
Joined: 14 Jan 2008
Total Posts: 3820
16 Jan 2012 08:45 AM
Wow...that was probably the biggest fail i've made in scripting...all i have to do is enable/disable the clickdetector 0_0
Report Abuse
iamwalker257 is not online. iamwalker257
Joined: 14 Jan 2008
Total Posts: 3820
16 Jan 2012 08:50 AM
...nvm...i still need help please
Report Abuse
352ynnhoj is not online. 352ynnhoj
Joined: 21 Sep 2010
Total Posts: 1054
16 Jan 2012 08:54 AM
output please...
Report Abuse
352ynnhoj is not online. 352ynnhoj
Joined: 21 Sep 2010
Total Posts: 1054
16 Jan 2012 08:55 AM
Also you didnt define what enable was.
Report Abuse
iamwalker257 is not online. iamwalker257
Joined: 14 Jan 2008
Total Posts: 3820
24 Jan 2012 04:31 PM
enabled is a variable within the script....it doesnt change anything outside the script (like ting = 1 and stuff like that)
Report Abuse
rcm is not online. rcm
Joined: 29 Jul 2008
Total Posts: 621
24 Jan 2012 05:24 PM
You shouldn't be remove()ing the click detector, since that disconnects the onClick() function. It looks like your just trying to make a 5 second debounce so try this:
(It sets the maxactivationdistance to 0 for 5 seconds, then back to 32)

enabled = true

function onClicked()
if not enabled then return end
enabled = false
script.Parent.ClickDetector.MaxActivationDistance = 0
local p = Instance.new("Part")
p.Position = script.Parent.Parent.Drop.Position
p.Size = Vector3.new(2,1,4)
p.Name = "CabbageBrick"
p.Parent = script.Parent.Parent.Parent

script.Parent.Transparency = 1
wait(5)
script.Parent.ClickDetector.MaxActivationDistance = 32
script.Parent.Transparency = 0
enabled = true
end

script.Parent.ClickDetector.MouseClick:connect(onClicked)
Report Abuse
iamwalker257 is not online. iamwalker257
Joined: 14 Jan 2008
Total Posts: 3820
27 Jan 2012 03:41 PM
oh yeah...i didnt think about that...thanks!
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