KodakKid3
|
  |
| Joined: 25 Dec 2008 |
| Total Posts: 2860 |
|
|
| 09 Mar 2014 01:52 PM |
I have a leaderboard that gives players money for doing things ingame. The money value is just called "Money". I made a gui that I want to use as a shop (The script would go inside a TextButton).
In Lighting is a tool called PowerShot, which I want to give to the player when he uses the shop for it (For 900 money).
This is the script I wrote:
local Mon = Player.Money.Value local PS = game.Lighting.PowerShot
function onClick() if Mon >= 900 then Mon = Mon - 900 --give player PS end end
MouseButton1Down:connect(onClick)
I obviously don't know what I'm doing.
Help? |
|
|
| Report Abuse |
|
|
|
| 09 Mar 2014 01:54 PM |
Connection line is the problem. Determin what is being clicked.
function onClick() if Mon >= 900 then Mon = Mon - 900 --give player PS end end
*PUT THE THING BEING CLICKED HERE*.MouseButton1Down:connect(onClick) |
|
|
| Report Abuse |
|
|
|
| 09 Mar 2014 01:54 PM |
Uh, no...
--Goes into LocalScript, in the text button
KeepGear = false --Do you want them to keep it when they die? If so, set to true.
function onClicked() if game.Players.LocalPlayer.leaderstats.Money.Value >= 900 then game.Lighting["Power Shot"]:Clone().Parent = game.Players.LocalPlayer.Backpack if KeepGear == true then game.Lighting["Power Shot"]:Clone().Parent = game.Players.LocalPlayer.StarterGear end end end script.Parent.Clicked:connect(onClicked) |
|
|
| Report Abuse |
|
|
KodakKid3
|
  |
| Joined: 25 Dec 2008 |
| Total Posts: 2860 |
|
|
| 09 Mar 2014 02:40 PM |
Thanks.
Thrashing, yours looks good (Not currently working), I'll see if I can fix whatever's wrong. |
|
|
| Report Abuse |
|
|
|
| 09 Mar 2014 05:01 PM |
It was the connection line, replace it with this:
script.Parent.MouseButton1Click:connect(onClicked) |
|
|
| Report Abuse |
|
|