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

How to make printing players amount of money?

I need change my gamepass prices less if player have more money. I tested with print and not worked. I tryed functions, while and not worked :(

local player = game.Players.LocalPlayer
local statss = player:WaitForChild ("leaderstats") 
local moneyss = stass:WaitForChild ("Money") 
local mony = moneyss.Value

while mony => 0 and <= 10 do
          print("0-10")
end

while mony =>11 and <= 20 do
           print("11-20")
end

7 comments

0

I wrote it on phone so print is little on right :D

0

Well, there are a lot of extremely silly mistakes in your code. First of all, your variable 'mony' is assigned with the value of 'moneyss'. This means that if the value is changed, it won't register as the Local Script only runs again (naturally) on respawn. So, to fix your first issue, Remove '.Value' in Line 04, and add '.Value' after 'mony' in Line 6 and Line 10.

0

The first fix ensures that the variable is getting the instance and not the value, and can be used further.

0

Your second issue is using two while loops, I might be wrong here, but to my experience, the code below any while loop doesn't get executed until break or return is used to break the loop. So, you using two while loops using is a bad idea. Instead, you can use GetPropertyChangedSignal : https://developer.roblox.com/en-us/api-reference/function/Instance/GetPropertyChangedSignal

0

And the final silly mistake is both in Line 6 and Line 10 again. I am going to be dividing the code in two parts of Line 6, Part 1 : while mony.Value >= (make sure to use correct operator for equal to or greater than) and Part 2 : and <= 10 do. And if you have spotted your mistake, the mistake is in Part 2. It's incomplete. Make sure to add mony.Value in Part 2 before operator in both the Lines.

0

Line 4 should look like -> mony:GetPropertyChangedSignal("Value"):Connect(function(); if mony.Value >= 0 and mony.Value <= 10 then; print('0-10'); elseif mony.Value >= 11 and mony.Value <= 20 then; print('11-20'); end; end) NOTE ; is used to determine line change. 'GetPropertyChangedsignal' will trigger when the property specified in the paranthesis[()] is changed.

0

Thx :D

2 answers

This isn't hard to do

local player = game.Players.LocalPlayer
local stats = player:WaitForChild("leaderstats")
local money = stats:WaitForChild("Money")

print(Money.Value)

1 comment

0

Yes but i need printing what i made because i will replace it with gamepass values to chamge it. :D

I think you can't make the Gamepass go down in price the more money you have, what you can do is create Developer Products with the prices you want, and put in your script that from "x" amount of money, the code of the Change Gamepass to one that is worth less.

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