Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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?

1 comment

0

Anyone? :(

3 answers

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

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.

2 comments

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 :)

0

Try without leaderstats in it then :P

This discussion is preserved as it was. New answers, comments, and votes are closed.