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

My script seems to be off about the Shop i made, Can anyone help me with it?

Asked by 7 years ago

By script was supposed to give you a sniper and takes away $100 then once you have it and its you're backpack you can't get another one. But the only thing that works is when it takes away the money.

Script:

01local Cash = game.Players.LocalPlayer.leaderstats.Cash -- change Cash to your currency
02function onClicked()
03if Cash.Value >= 100 then --change 350000 to the amount it costs
04Cash.Value = Cash.Value - 100 --change 350000 to the amount it costs
05end
06end
07 
08script.Parent.MouseButton1Down:connect(onClicked)
09 
10local price = script.Parent.Parent.BuyNowSniper
11local Player = script.Parent.Parent.Parent.Parent.Players.LocalPlayer
12 
13Tool = script.Parent
14 
15Tool.Equipped:connect(function()
View all 27 lines...

what do i need remove or add? Thanks, Peace :3

1 answer

Log in to vote
0
Answered by
Viking359 161
7 years ago

Next time, dont use a free model. Also, make sure this is in a local script if you are using local player.

01local player = game.Players.LocalPlayer
02local Cash = player.leaderstats.Cash
03local price = 100
04local backpack = player.Backpack
05local text = "Whatever the textbutton says right now"
06script.Parent.MouseButton1Down:Connect(function(onClicked)
07if Cash.Value >= price and backpack:FindFirstChild("Sniper") == nil then
08Cash.Value = Cash.Value - price
09local tool = script.Parent.Sniper:Clone()
10tool.Parent = backpack
11local Tool = tool:Clone()
12tool.Parent = player.StarterPack
13elseif backpack:FindFirstChild("Sniper") then
14    script.Parent.Text = "You already have that!"
15    wait(1)
View all 26 lines...

I'm assuming the sniper is a child of the text button, along with the script.

Ad

Answer this question