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).
local price = script.Parent.Parent.Price local tools = game.ReplicatedStorage:WaitForChild("Tools") local tool = tools:FindFirstChild(script.Parent.Parent.ItemNameValue.Value) local player = game.Players.LocalPlayer local cash = player.leaderstats:WaitForChild("Cash") local Purchased1 = script.Parent.Parent.Parent.Frame.Item1.Purchased local Purchased2 = script.Parent.Parent.Parent.Frame.Item2.Purchased local Purchased3 = script.Parent.Parent.Parent.Frame.Item3.Purchased if script.Parent.Parent.Purchased.Value == 0 then print("=0") if script.Parent.Parent.Purchased.Value == 1 then print("script") end end script.Parent.MouseButton1Click:Connect(function() if cash.Value >= price.Value then cash.Value = cash.Value - price.Value end if price.Value == 100 then local oldGun = player.Backpack:FindFirstChildOfClass("Tool") or player.Character:FindFirstChildOfClass("Tool") oldGun:Destroy() game.ReplicatedStorage.Tools.Pistol:Clone().Parent = player.Backpack Purchased1.Value = 1 end if price.Value == 300 then local oldGun = player.Backpack:FindFirstChildOfClass("Tool") or player.Character:FindFirstChildOfClass("Tool") oldGun:Destroy() game.ReplicatedStorage.Tools.Revolver:Clone().Parent = player.Backpack Purchased2.Value = 1 end if price.Value == 500 then local oldGun = player.Backpack:FindFirstChildOfClass("Tool") or player.Character:FindFirstChildOfClass("Tool") oldGun:Destroy() game.ReplicatedStorage.Tools.Uzi:Clone().Parent = player.Backpack Purchased3.Value = 1 end end)
My problem is that when the intvalue == 1 it doesnt print("BYU")
**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:
if script.Parent.Parent.Purchased.Value == 0 then print("=0") elseif script.Parent.Parent.Purchased.Value == 1 then 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. end
Hope this works.
game.Players.PlayerAdded:Connect(function(player) player.CharacterAdded:Connect(function(character) if game.MarketplaceService:PlayerOwnsAsset(player,ID) then --The id is the id of the gamepass your selling SCIPRT HERE -- what you want executed when the player owns the gamepass end end) end)