Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Script Timeout Even Though Everything Is Fine?

I don't understand why this happened? I have debounce and everything. This script is checking if the player owns a certain tool and if they do it'll make the equip button visible?

Any ideas why this is happening

Local Script

local Event = game.ReplicatedStorage.EggTrayEvents.PurchaseEggTray

local Price = script.Parent.Price.Value

local Storage = script.Parent.MaxStorage.Value

local Name = script.Parent.NameOFItem.Value

local Ownership = false

local Player = game.Players.LocalPlayer

local MC = Player:WaitForChild("MainCurrency")

local Coins = MC:FindFirstChild("Tokens")

local PouchCheck = Player:WaitForChild("EggTrayOwned")

local PouchEquipped = Player:WaitForChild("EggTrayEquipped")

local PE1 = PouchEquipped:WaitForChild("EggTray2E")  -- Just Change The Num Each Time

local PO1 = PouchCheck:WaitForChild("EggTO2") -- Just Change The Num Each Time

local debounce = false
----------------------------

while debounce == false do
	
	if MC and PO1.Value == false then
		
		script.Parent.MouseButton1Click:Connect(function()
			
		if Coins.Value >= Price then
			
			debounce = true
			
			Ownership = true
			
			Event:FireServer(Name, Price, Storage, Ownership)
			
			print("Fired")
			
			script.Parent.Parent.PS:Play()
			
			script.Parent.Visible = false
			
			script.Parent.Parent.Equip.Visible = true
		else
			
			debounce = true
			
			script.Parent.RoundIf.NameLab.Text = "Ins Tokens"
			script.Parent.RoundIf.NameLab.TextColor3 = Color3.fromRGB(255,0,0)
			
			script.Parent.Parent.ER:Play()
			
			wait(1)
			
			script.Parent.RoundIf.NameLab.Text = "BUY"
			script.Parent.RoundIf.NameLab.TextColor3 = Color3.fromRGB(255,255,255)
			
			debounce = false
			
			
			
			end
		end)
			
			
	elseif MC and PO1.Value == true then
			
			debounce = true
			
			script.Parent.Visible = false
			script.Parent.Parent.Equip.Visible = true
				
end
end

2 answers

This script works but it purchases the gear more than once?

Local Script

local Event = game.ReplicatedStorage.EggTrayEvents.PurchaseEggTray

local Price = script.Parent.Price.Value

local Storage = script.Parent.MaxStorage.Value

local Name = script.Parent.NameOFItem.Value

local Ownership = false

local Player = game.Players.LocalPlayer

local MC = Player:WaitForChild("MainCurrency")

local Coins = MC:FindFirstChild("Tokens")

local PouchCheck = Player:WaitForChild("EggTrayOwned")

local PouchEquipped = Player:WaitForChild("EggTrayEquipped")

local PE1 = PouchEquipped:WaitForChild("EggTray1E")  -- Just Change The Num Each Time

local PO1 = PouchCheck:WaitForChild("EggTO1") -- Just Change The Num Each Time

----------------------------

	if MC and PO1.Value == false then
		
		script.Parent.MouseButton1Click:Connect(function()
			
		if Coins.Value >= Price then
			
			Ownership = true
			
			Event:FireServer(Name, Price, Storage, Ownership)
			
			print("Fired")
			
			script.Parent.Parent.PS:Play()
			
			script.Parent.Visible = false
			
			script.Parent.Parent.Equip.Visible = true
		else
			
			script.Parent.RoundIf.NameLab.Text = "Ins Tokens"
			script.Parent.RoundIf.NameLab.TextColor3 = Color3.fromRGB(255,0,0)
			
			script.Parent.Parent.ER:Play()
			
			wait(1)
			
			script.Parent.RoundIf.NameLab.Text = "BUY"
			script.Parent.RoundIf.NameLab.TextColor3 = Color3.fromRGB(255,255,255)
			
			
			
			end
		end)
			
			
		elseif MC and PO1.Value == true then
			script.Parent.Visible = false
			script.Parent.Parent.Equip.Visible = true
				
end

1 comment

0

??

Put a wait() right on the top of the while loop.

2 comments

0

I fixed it, put debounce in the wrong place lol

0

Could you mark my answer as correct plz?

This discussion is preserved as it was. New answers, comments, and votes are closed.