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
 

Egg Script Help

Previous Thread :: Next Thread 
silverswordgold2 is not online. silverswordgold2
Joined: 02 Sep 2011
Total Posts: 1598
31 Mar 2013 10:22 AM
I have this inside an egg on my game, and when you click on it, it changes the transparency of the egg, and adds a point on your "egg" leaderboard. Why is this not working? I don't think I need a debounce.


Instance.new("ClickDetector", script.Parent)
local p = script.Parent
function onClick()

check = click.Parent:FindFirstChild("Humanoid")

if check ~= nil then

p.Transparency = 1
wait(0.2)
local user = game.Players:GetPlayerFromCharacter(click.Parent)
local stats = user:findFirstChild("leaderstats")

if stats ~= nil then
local cash = stats:findFirstChild("Eggs")
cash.Value = cash.Value +1
p.Transparency = 0
wait(50)
end
end
end

p.ClickDetector.MouseClick:connect(onClick)
Report Abuse
silverswordgold2 is not online. silverswordgold2
Joined: 02 Sep 2011
Total Posts: 1598
31 Mar 2013 10:24 AM
please help
Report Abuse
zakneifian is not online. zakneifian
Joined: 03 Mar 2010
Total Posts: 119
31 Mar 2013 10:29 AM
IM KIND OF A NOOB YET but, shouldnt it be
Instance.new("ClickDetector", script.Parent) -- if you want it to be father of script shouldnt it be instead off "script.Parent", "Workspace.Object" supposing the father of the script is Object

local p = script.Parent -- same here shouldnt you start with Workspace (?)
function onClick()


i have not read more than here
Report Abuse
badcc is not online. badcc
Joined: 18 Jan 2009
Total Posts: 3170
31 Mar 2013 10:29 AM
I did not read it through, but I recall that ROBLOX just recently broke ClickDetectors. Haven't tried it myself, but that's what I have been hearing.
Report Abuse
zakneifian is not online. zakneifian
Joined: 03 Mar 2010
Total Posts: 119
31 Mar 2013 10:30 AM
is it script a variable?
Report Abuse
seanb117 is not online. seanb117
Joined: 03 Feb 2010
Total Posts: 1020
31 Mar 2013 10:34 AM
ClickDetectors are automatically created...
Report Abuse
digpoe is not online. digpoe
Joined: 02 Nov 2008
Total Posts: 9092
31 Mar 2013 10:34 AM
No they're not.
Report Abuse
seanb117 is not online. seanb117
Joined: 03 Feb 2010
Total Posts: 1020
31 Mar 2013 10:48 AM
Actually they are. If you script it right, you don't need to make a clickdetector in the model.
Report Abuse
digpoe is not online. digpoe
Joined: 02 Nov 2008
Total Posts: 9092
31 Mar 2013 10:49 AM
Obviously if you use Instance.new() to create a ClickDetector, then no you don't need one in by default.

But if you're not, you do need one in the part.
Report Abuse
seanb117 is not online. seanb117
Joined: 03 Feb 2010
Total Posts: 1020
31 Mar 2013 10:59 AM
I have never had to add that to a script, it always auto created one for me.
Report Abuse
seanb117 is not online. seanb117
Joined: 03 Feb 2010
Total Posts: 1020
31 Mar 2013 11:01 AM
Nevermind, I was thinking of TouchInterest.
Report Abuse
Desperian is not online. Desperian
Joined: 07 Feb 2012
Total Posts: 3371
31 Mar 2013 11:51 AM
You've not defined 'click', among other small issues. Also, the ClickDetector gives you the player object, not the character.

local ClickDetector = Instance.new("ClickDetector", script.Parent)

function onClick(Clicker) -- Functions can be named anything.
script.Parent.Transparency = 1
ClickDetector.MaxActivationDistance = 0
if Clicker:findFirstChild("leaderstats") then
Clicker.leaderstats.Eggs.Value = Clicker.leaderstats.Eggs.Value +1
wait(50)
script.Parent.Transparency = 0
ClickDetector.MaxActivationDistance = 32
end
end

ClickDetector.MouseClick:connect(onClick)


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