So I am making a new game.. And I really need this for it because its a simulator. I dont have any code because I cant seem to get the value of the NumberValue item.
There are a few ways to do this, and it all depends on what you are trying to do. The simplest way to do it is this:
1 | local TheValueObject = game.Workspace.NumberValue --This is where you have the little value object |
2 |
3 | Event:Connect( function () --The event that makes it want the check the value |
4 | if TheValueObject.Value = = TheNumberYouWant then --This is where you check to see if the value is what you want |
5 |
6 | --This is where you have it do the stuff |
7 |
8 | end ) |
Hello, SGYTMinersHaven!
To get a VALUE value's you use .Value
after the value's position!
Example:
1 | -- Let's say if the script is a child of the value |
2 | -- This script will print the value |
3 | print (script.Parent.Value) |
To set a new value for the VALUE you do like any var!
Example:
1 | -- Let's say if the script is a child of the value |
2 | -- The script will add 1 to the value |
3 | script.Parent.Value = script.Parent.Value + 1 |
Good Luck with your games!
Well, first friend will need a leaderstats to add cash among other things
This an Example : (> https://wiki.roblox.com/index.php?title=Leaderboards <)
01 | game.Players.PlayerAdded:connect( function (player) |
02 | local leaderstats = Instance.new( "IntValue" ) |
03 | leaderstats.Name = "leaderstats" |
04 | leaderstats.Parent = player |
05 |
06 | local money = Instance.new( "IntValue" ) --We create a new IntValue |
07 | money.Name = "Money" --this is the name you want the leader-stat to be when it shows up in-game. |
08 | money.Value = 0 --this is the value of money the new player starts out with. To change this, you can add some more code (shown later) |
09 | money.Parent = leaderstats -- Set the money object as a child of the leaderstats object. |
10 | end ) |
For you to determine if something is activated through Money you can use "<" to determine how much money I need to activate this function
This an Example : (This script will only release this function when the player is 50)
01 | local player = game.Players.LocalPlayer |
02 | local uis = game:GetService( "UserInputService" ) |
03 | local value = 50 -- Money Need to active this function |
04 |
05 | uis.InputBegan:Connect( function (key) |
06 | if key.KeyCode = = Enum.KeyCode.V then |
07 | if player.leaderstats.Money.Value < value then return end |
08 | print ( "Player Have Acess" ) |
09 | if not player.leaderstats.Money.Value < value then |
10 | print ( "Player dont have acess" ) |
11 | end |
12 | end |
13 | end ) |