local frame = script.Parent local textBox = script.Parent local open = workspace.openPart local close = workspace.closePart local closeBtn = frame.CloseButton local Players = game:GetService("Players") local localPlayer = Players.LocalPlayer local Gold = localPlayer.leaderstats.Gold local errorGui = localPlayer.PlayerGui:WaitForChild("ErrorGui") local ReplicatedStorage = game:GetService("ReplicatedStorage") local remoteEvent = ReplicatedStorage.buySeeds frame.Visible = false errorGui.Enabled = false local price = { ['Wheat'] = 100, ['Corn'] = 250, ['Rice'] = 2000, ['Bamboo'] = 8400, ['Soybean'] = 24000, ['Cabbage'] = 57600, ['Carrot'] = 85000, ['Potato'] = 120000 } for _,UI in pairs(script.Parent:GetDescendants()) do if UI:IsA('TextButton') then UI.MouseButton1Click:Connect(function(ItemName, player) local AmountPurchase = tonumber(UI.Parent:FindFirstChildOfClass('TextBox').Text) local Seed = UI.Parent:FindFirstChildOfClass('TextBox').Name:gsub('BuyAmount','') --Loops through how many times you entered in the box to purchase if AmountPurchase then for i=1,AmountPurchase do print(Gold.Value, price[Seed]) if Gold.Value >= price[Seed] then Gold.Value -= price[Seed] remoteEvent:FireServer(Seed.Name) print("Successfully Purchased") elseif Gold.Value < price[Seed] then print("Insufficient Funds") errorGui.Enabled = true end end end end) end end local function openMenu(otherPart) frame.Visible = true local player = Players:GetPlayerFromCharacter(otherPart.Parent) if player.Name == localPlayer.Name then localPlayer.Character.Humanoid.WalkSpeed = 0 end end local function closeMenu() frame.Visible = false localPlayer.Character.HumanoidRootPart.CFrame = CFrame.new( close.Position.X, close.Position.Y + 3, close.Position.Z) localPlayer.Character.Humanoid.WalkSpeed = 16 end open.Touched:Connect(openMenu) closeBtn.MouseButton1Click:Connect(closeMenu)
your using :GetDescendants()
which mgiht find stuff that isn't parented to the same parent as the textbox, try adding an if statement to see if it finds it