|
| 10 Oct 2013 03:44 PM |
points = plyr.leaderstats.Points.Value
function onClicked(plyr) if points > 9 then points = points - 10 else m = Instance.new("Message") m.Parent = plyr.PlayerGui m.Text = "Not enough points" wait(3) m:remove() end end
script.Parent.ClickDetector.MouseClick:connect(onClicked)
It's for a leaderboard that I made. I wanna make it into a shop. But when I click the brick nothing happens. What's wrong? |
|
|
| Report Abuse |
|
|
|
| 10 Oct 2013 03:45 PM |
| Define the Points Variable inside the click function try that |
|
|
| Report Abuse |
|
|
MXrcr20
|
  |
| Joined: 01 Oct 2008 |
| Total Posts: 2644 |
|
|
| 10 Oct 2013 03:45 PM |
| Put "points = plyr.leaderstats.Points.Value" inside of the function body. |
|
|
| Report Abuse |
|
|
|
| 10 Oct 2013 03:46 PM |
| plyr is only defined inside your function, therefore it is not global. |
|
|
| Report Abuse |
|
|
|
| 10 Oct 2013 03:48 PM |
Like this?
function onClicked(plyr) points = plyr.leaderstats.Points.Value if points > 9 then points = points - 10 else m = Instance.new("Message") m.Parent = plyr.PlayerGui m.Text = "Not enough points" wait(3) m:remove() end end
script.Parent.ClickDetector.MouseClick:connect(onClicked) |
|
|
| Report Abuse |
|
|
|
| 10 Oct 2013 03:49 PM |
| Yeah, but make it local so you don't get any dumb errors. |
|
|
| Report Abuse |
|
|