Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Shop gui doesn't take away gold, no output??

Asked by
aews5 15
11 years ago

In my roblox game, I am making a shop gui except it does not take away gold. It will give them the extra speed as long as they have enough gold.

1player = script.Parent.Parent.Parent.Parent.Parent.Parent
2Gold = player.leaderstats.Gold.Value
3cost = 25
4script.Parent.MouseButton1Click:connect(function()
5    if Gold>=cost then
6        Gold = Gold - cost
7        player.GuardSpeed.Value = player.GuardSpeed.Value + 1
8    end
9end)

Can anyone help?

0
Anyone? :( aews5 15 — 11y

3 answers

Log in to vote
0
Answered by 11 years ago

Did you define cost?

0
cost = 25 aews5 15 — 11y
Ad
Log in to vote
0
Answered by
anerth 25
11 years ago

did you make a part that says leaderboardstat = leaderboardstat - cost

Log in to vote
0
Answered by
Dummiez 360 Moderation Voter
11 years ago

Alright so I went a go at it since I thought that since GuardSpeed is a value shouldn't it be in leaderstats? Also make sure that player actually goes to player. There's quite a number of parents lol.

And cost is declared, just clearing it for everyone.

01player = script.Parent.Parent.Parent.Parent.Parent.Parent -- Make sure this is actually leads to the 'player'
02 
03script.Parent.MouseButton1Click:connect(function()
04 
05local sGold = player.leaderstats["Gold"]
06local sGuardSpeed = player["GuardSpeed"]
07local sCost = 25;
08 
09    if sGold.Value >= sCost then
10        sGold.Value = sGold.Value - sCost
11        sGuardSpeed.Value = sGuardSpeed.Value + 1
12        print('Purchased speed thingy')
13    else print('Insufficient funds')
14    end
15end)

EDIT: Removed leaderstat value from GuardSpeed.

0
GuardSpeed isn't meant to appear in the leaderstats, it's just so they don't get the speed everywhere / not as the guard, it takes that value and sets it as their speed if they are the guard, then resets it :) aews5 15 — 11y
0
Try without leaderstats in it then :P Dummiez 360 — 11y

Answer this question