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

If person buys item then intvalue goes from 0 to 1. If value = 1 then it prints("BYU") How fix?

Asked by 5 years ago
Edited 5 years ago

So I made a shop Gui and whenever you buy an item it changes the text from "Buy!" to purchased. I made the script so that when ever you buy an item it changes the IntValue called Purchase to 1(Meaning they bought it).

01local price = script.Parent.Parent.Price
02local tools = game.ReplicatedStorage:WaitForChild("Tools")
03local tool = tools:FindFirstChild(script.Parent.Parent.ItemNameValue.Value)
04 
05local player =  game.Players.LocalPlayer
06local cash = player.leaderstats:WaitForChild("Cash")
07local Purchased1 = script.Parent.Parent.Parent.Frame.Item1.Purchased
08local Purchased2 = script.Parent.Parent.Parent.Frame.Item2.Purchased
09local Purchased3 = script.Parent.Parent.Parent.Frame.Item3.Purchased
10 
11if script.Parent.Parent.Purchased.Value == 0 then
12    print("=0")
13    if script.Parent.Parent.Purchased.Value == 1 then
14        print("script")
15    end
View all 39 lines...

My problem is that when the intvalue == 1 it doesnt print("BYU")

2 answers

Log in to vote
0
Answered by 5 years ago

**Lines 11-16 combat each other, because you're making the script check if the value of "Purchased" if set to 1 when it checked it as 0. ** Whenever the code runs, it checks if the value is 0. If it is, it then checks if it is 1. Separate the two by putting in the following code for lines 11-16:

1if script.Parent.Parent.Purchased.Value == 0 then
2    print("=0")
3elseif script.Parent.Parent.Purchased.Value == 1 then
4    print("BYU") -- If it prints "BYU" when the item is bought and it shouldn't do that, just change what is printed in this line.
5end

Hope this works.

0
okthx GunzerkingBeast21 -4 — 5y
0
If it works accept the answer so we know it's done Robloxian_Hero1234 14 — 5y
Ad
Log in to vote
0
Answered by 5 years ago
1game.Players.PlayerAdded:Connect(function(player)
2    player.CharacterAdded:Connect(function(character)
3        if game.MarketplaceService:PlayerOwnsAsset(player,ID) then --The id is the id of the gamepass your selling
4            SCIPRT HERE -- what you want executed when the player owns the gamepass
5        end
6    end)
7end)

Answer this question