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).
01 | local price = script.Parent.Parent.Price |
02 | local tools = game.ReplicatedStorage:WaitForChild( "Tools" ) |
03 | local tool = tools:FindFirstChild(script.Parent.Parent.ItemNameValue.Value) |
05 | local player = game.Players.LocalPlayer |
06 | local cash = player.leaderstats:WaitForChild( "Cash" ) |
07 | local Purchased 1 = script.Parent.Parent.Parent.Frame.Item 1. Purchased |
08 | local Purchased 2 = script.Parent.Parent.Parent.Frame.Item 2. Purchased |
09 | local Purchased 3 = script.Parent.Parent.Parent.Frame.Item 3. Purchased |
11 | if script.Parent.Parent.Purchased.Value = = 0 then |
13 | if script.Parent.Parent.Purchased.Value = = 1 then |
17 | script.Parent.MouseButton 1 Click:Connect( function () |
18 | if cash.Value > = price.Value then |
19 | cash.Value = cash.Value - price.Value |
21 | if price.Value = = 100 then |
22 | local oldGun = player.Backpack:FindFirstChildOfClass( "Tool" ) or player.Character:FindFirstChildOfClass( "Tool" ) |
24 | game.ReplicatedStorage.Tools.Pistol:Clone().Parent = player.Backpack |
27 | if price.Value = = 300 then |
28 | local oldGun = player.Backpack:FindFirstChildOfClass( "Tool" ) or player.Character:FindFirstChildOfClass( "Tool" ) |
30 | game.ReplicatedStorage.Tools.Revolver:Clone().Parent = player.Backpack |
33 | if price.Value = = 500 then |
34 | local oldGun = player.Backpack:FindFirstChildOfClass( "Tool" ) or player.Character:FindFirstChildOfClass( "Tool" ) |
36 | game.ReplicatedStorage.Tools.Uzi:Clone().Parent = player.Backpack |
My problem is that when the intvalue == 1 it doesnt print("BYU")