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

How do you make it if they have enough of cash they get an item added to their starter pack?

Like of their cash reaches 20 they get a sword and if it reaches 50 they get. Magic. (Btw i have a cash auto. Riser )

2 comments

0

Use a conditional statement of the form "if Cash.Value == 20 then... ".

0

not constructive kek

4 answers

✓ Accepted answer

Example: This is for 'SHOP'

player = script.Parent.Parent.Parent.Parent.Parent


local tool = game.ServerStorage:FindFirstChild("NAME OF TOOL HERE") -- Make sure to put the tool in ServerStorage!


Balance = 100 -- Set here how much money you want for this item to cost!


money = player.leaderstats.CURRENCY



-- This script uses TextButton, or ImageButton1
script.Parent.MouseButton1Click:connect(function()
if money.Value >= Balance then


local item = tool:Clone()
item.Parent = player.Backpack


money.Value = money.Value - Balance -- Remove this line if you want that you don't lose your money when you purchase this item! Otherwise, leave this!
end
end)


EXAMPLE: This is automatically giver.

-- VARIABLES

player = script.Parent.Parent.Parent.Parent.Parent


local tool = game.ServerStorage:FindFirstChild("NAME OF TOOL HERE") -- Make sure to put the tool in ServerStorage!


Balance = 100 -- Set here how much money you want for this item to cost!


money = player.leaderstats.CURRENCY


-- CODING

if money.Value >= Balance then

local item = tool:Clone()
item.Parent = player.Backpack

end

That's it, btw sorry for my bad English! If this script worked for you, feel free to accept my answer!

Use something along these lines

if Money.Value >= 20 then

 --or

if Money.Value >= 50 then

Here is an example:

local item = game.ReplicatedStorage.item:clone
if Cash.Value >= 100 then
    item.Parent = game.Players.LocalPlayer.Backpack
end

Change things up a little if it didn't work. I'm just new to RBLX Lua.

1 comment

0

lol your script is broken.

magic = game. -- put magic's path.
sword = game. -- put sword's path
money = game. -- put money's path
plr = game.Players.LocalPlayer

if money.Value >= 20 then
magic:Clone().Parent = plr.Backpack
end

if money.Value >= 50 then
sword:Clone().Parent = plr.Backpack
end

2 comments

0

so what do you mean when you say path?do you mean replicated storage?

0

for example let's say sword is located in ReplicatedStorage you do this game.ReplicatedStorage.sword

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