This is my Buying Script I have all my variables set up correctly

game.Players.PlayerAdded:Connect(function(player)
	local Buy = player.PlayerGui:WaitForChild("Gui").Main.Info.Buy
	local leaderstats = player:FindFirstChild("leaderstats")
	local Cash = leaderstats:FindFirstChild("Cash")
	local price = player.PlayerGui:WaitForChild("Gui").Main.Info.Price
	local Gui = player.PlayerGui:WaitForChild("Gui").Main.Frame
	local Purchased1 = Gui.Item1.Purchased
	local Purchased2 = Gui.Item2.Purchased
	local Purchased3 = Gui.Item3.Purchased
	
	
	Buy.MouseButton1Click:connect(function()
		if Cash.Value >= price.Value then
		Cash.Value = Cash.Value - price.Value
		print("Yeet")
			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
			end)
		end)

1 comment

0

Your question is not anymore descriptive or specific. Read the reason as to why it was closed. "This question has been closed because it is too broad and is generally unanswerable. Please ask a more specific question". More information than that is needed https://scriptinghelpers.org/help/how-post-good-questions-answers.