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

currency not turning into other currency?

Asked by
3wdo 198
5 years ago
Edited 5 years ago

i am making a cash to gold system where if the player get 10,000 cash it would turn into gold. there are no errors but its not turning into gold here is me script:

01game.Players.PlayerAdded:Connect(function(player)
02    local stats = Instance.new("Folder",player)
03    stats.Name = "leaderstats"
04 
05    local cash = Instance.new("IntValue",stats)
06    cash.Name = "Cash"
07    cash.Value = 10
08 
09    local gold = Instance.new("IntValue",stats)
10    gold.Name = "Gold"
11    gold.Value = 0
12 
13 
14    cash.Changed:Connect(function()
15        player.leaderstats.Cash.Value = player.leaderstats.Cash.Value - 0 -- this takes away the cash
16        player.leaderstats.Gold.Value = player.leaderstats.Gold.Value + 1
17 
18    end)
19end)
0
when a reputation 100+ says a question is a "request" but it doesn't ask for anything but help on scripting speedyfox66 237 — 5y

1 answer

Log in to vote
0
Answered by
BashGuy10 384 Moderation Voter
5 years ago
Edited 5 years ago

Hi, i'm BashGuy10. I can hopefully help you!

Problem?

You're currency is not changing correctly.

Fixes

Use while wait() do or Cash.Changed:Connect(function()

Fix

01game.Players.PlayerAdded:Connect(function()
02    -- Leader stat creation here
03 
04 
05    cash.Changed:Connect(function()
06        if player.leaderstats.Cash.Value >= 10000 then
07            player.leaderstats.Cash.Value = 0 -- Set the value = 0
08 
09            player.leaderstats.Gold.Value = player.leaderstats.Gold.Value + 1
10        end
11    end)
12end)

FYI, paste you leaderstat code in to Line 2, and paste gold changing code into Line 6

Roblox wiki link

0
Btw i recommend "Cash.Changed" BashGuy10 384 — 5y
0
i now got an error: ServerScriptService.Script:22: unexpected symbol near ')' 3wdo 198 — 5y
0
i tried cash.Changed and it says: ServerScriptService.Script:22: 'end' expected (to close 'function' at line 1) near '<eof>' 3wdo 198 — 5y
0
Changed it BashGuy10 384 — 5y
View all comments (7 more)
0
If it still doesn't work, tell me. BashGuy10 384 — 5y
0
it worked but it didnt take away the cash 3wdo 198 — 5y
0
Please update your answer with your code BashGuy10 384 — 5y
0
I found your problem, im about to edit my answer BashGuy10 384 — 5y
0
Please mark this as the solution if i fixed your problem BashGuy10 384 — 5y
0
thank you 3wdo 198 — 5y
0
No problem bro BashGuy10 384 — 5y
Ad

Answer this question