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

How to make printing players amount of money?

Asked by 3 years ago

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
0
I wrote it on phone so print is little on right :D moneyislands1 51 — 3y
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. BestCreativeBoy 1395 — 3y
0
The first fix ensures that the variable is getting the instance and not the value, and can be used further. BestCreativeBoy 1395 — 3y
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 BestCreativeBoy 1395 — 3y
View all comments (3 more)
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. BestCreativeBoy 1395 — 3y
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. BestCreativeBoy 1395 — 3y
0
Thx :D moneyislands1 51 — 3y

2 answers

Log in to vote
0
Answered by
MattVSNNL 620 Moderation Voter
3 years ago
Edited 3 years ago

This isn't hard to do

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

print(Money.Value)
0
Yes but i need printing what i made because i will replace it with gamepass values to chamge it. :D moneyislands1 51 — 3y
Ad
Log in to vote
0
Answered by 3 years ago

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.

Answer this question