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

Help i want my Item a 1 Time PURCHASE!?

Asked by
Tizzel40 243 Moderation Voter
5 years ago

so here I am, making a fire ball game and so there are different types of fire balls

when you press "F" the fire ball that you equipped will be shot

I had made a shop where you can buy different types of fireballs and basicly equip them with "bool Values"

so I made a bool value called "hasiceball" which is false and "hasfireball" which is also false.

so when I press the buy button which is the script below it will purchase the "ice fire ball" and by doing that it setts "hasiceball" to true and setts all other bool values to false like "hasfireball" would be set to false if true...

local items = game.Players.LocalPlayer:WaitForChild("FruitFolder")
local bitems = game.Players.LocalPlayer:WaitForChild("BoughtFolder")
local player = game:GetService("Players").LocalPlayer
--local rep = game:GetService"ReplicatedStorage"
--local tool = rep:FindFirstChild"HexSpitter"
local amt = 800
local money = player.leaderstats.Cash

script.Parent.MouseButton1Click:Connect(function()
    if bitems.Bhasiceball.Value == false and money.Value >= amt then
    money.Value = money.Value - amt

        items.hasiceball.Value = true
    items.haspoiball.Value = false
    items.hasspamball.Value = false
    items.hassniperball.Value = false
    items.hasfireball.Value = false
    items.hasregball.Value = false
end
end)

so when I tested I noticed that when I pressed buy for the "fireball" I got the FireBall but when I got back the ice ball I Had to Pay Again... so that's my problem

how do I make it so its a 1 time buy when you equip another fire ball and when a player leaves the game (I don't want it so you have to pay constantly!) ?

please help me.

0
I'm pretty sure you would have to store data for each player about what fireball's they have set to true and which ones the have set to false (I'm not sure as I have not learned this yet). But I know how to fix the problem within the game itself. Remove lines 14-18 and you should be good. Lines 14-18 sets all the other fireballs to false (you don't want that). RAYAN1565 691 — 5y
0
its gamepasses you know mlgwinners 30 — 5y

1 answer

Log in to vote
0
Answered by
RAYAN1565 691 Moderation Voter
5 years ago
Edited 5 years ago

Change your script to the following:

local items = game.Players.LocalPlayer:WaitForChild("FruitFolder")
local bitems = game.Players.LocalPlayer:WaitForChild("BoughtFolder")
local player = game:GetService("Players").LocalPlayer
--local rep = game:GetService"ReplicatedStorage"
--local tool = rep:FindFirstChild"HexSpitter"
local amt = 800
local money = player.leaderstats.Cash

script.Parent.MouseButton1Click:Connect(function()
    if bitems.Bhasiceball.Value == false and money.Value >= amt then
money.Value = money.Value - amt
items.hasiceball.Value = true
end
end)

To keep this a one-time purchase for eternity, you must do a data store. Click on the link to see how you would do that .

Update: I found another useful link.

0
You'd need remotes as DataStoreService is inaccessible by clients. User#19524 175 — 5y
0
@incapaz I don't understand. RAYAN1565 691 — 5y
0
@incapaz, can you answer this question so I can learn how to do that? RAYAN1565 691 — 5y
Ad

Answer this question