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
10 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.

player = script.Parent.Parent.Parent.Parent.Parent.Parent 
Gold = player.leaderstats.Gold.Value
cost = 25
script.Parent.MouseButton1Click:connect(function()
    if Gold>=cost then
        Gold = Gold - cost
        player.GuardSpeed.Value = player.GuardSpeed.Value + 1
    end
end)

Can anyone help?

0
Anyone? :( aews5 15 — 10y

3 answers

Log in to vote
0
Answered by 10 years ago

Did you define cost?

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

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

Log in to vote
0
Answered by
Dummiez 360 Moderation Voter
10 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.

player = script.Parent.Parent.Parent.Parent.Parent.Parent -- Make sure this is actually leads to the 'player'

script.Parent.MouseButton1Click:connect(function()

local sGold = player.leaderstats["Gold"]
local sGuardSpeed = player["GuardSpeed"]
local sCost = 25;

    if sGold.Value >= sCost then
        sGold.Value = sGold.Value - sCost
        sGuardSpeed.Value = sGuardSpeed.Value + 1
        print('Purchased speed thingy')
    else print('Insufficient funds')
    end
end)

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 — 10y
0
Try without leaderstats in it then :P Dummiez 360 — 10y

Answer this question