|
| 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 |
|
|
| |
|
|
| 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
|
  |
| 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 |
|
|
| |
|
seanb117
|
  |
| Joined: 03 Feb 2010 |
| Total Posts: 1020 |
|
|
| 31 Mar 2013 10:34 AM |
| ClickDetectors are automatically created... |
|
|
| Report Abuse |
|
|
digpoe
|
  |
| Joined: 02 Nov 2008 |
| Total Posts: 9092 |
|
| |
|
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
|
  |
| 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
|
  |
| 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
|
  |
| Joined: 03 Feb 2010 |
| Total Posts: 1020 |
|
|
| 31 Mar 2013 11:01 AM |
| Nevermind, I was thinking of TouchInterest. |
|
|
| Report Abuse |
|
|
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 |
|
|