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
 

Why doesn't my script work.

Previous Thread :: Next Thread 
randomname5k is not online. randomname5k
Joined: 12 Aug 2009
Total Posts: 8892
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
Andrew1234567mmm is not online. Andrew1234567mmm
Joined: 14 Oct 2009
Total Posts: 691
10 Oct 2013 03:45 PM
Define the Points Variable inside the click function try that
Report Abuse
MXrcr20 is not online. 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
JoshuaKempfert is not online. JoshuaKempfert
Joined: 16 Feb 2013
Total Posts: 2407
10 Oct 2013 03:46 PM
plyr is only defined inside your function, therefore it is not global.
Report Abuse
randomname5k is not online. randomname5k
Joined: 12 Aug 2009
Total Posts: 8892
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
JoshuaKempfert is not online. JoshuaKempfert
Joined: 16 Feb 2013
Total Posts: 2407
10 Oct 2013 03:49 PM
Yeah, but make it local so you don't get any dumb errors.
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