Hello everyone. I recently started making a self check-in and ran into a problem. I made it so when you step on a specific part, a GUI pops up and then gives you a tool. The problem is, if you keep touching the part the GUI keeps popping up. I do not want to use debounce because that would cause everyone not to be able to use the GUI and not just the one person. How do I make the script so it searches through the players backpack and if it finds a certain tool, it does not allow the GUI to pop up? Thanks.
Script:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local debounce = false
local Values = script.Parent.Values
local BusinessClassName = Values.BusinessClassName.Value
local BusinessClassTicket = Values.BusinessClassTicket
local BusinessRank = Values.BusinessRank.Value
local Class3 = Values.Class3.Value
local EconomyClassName = Values.EconomyClassName.Value
local EconomyClassTicket = Values.EconomyClassTicket
local EconomyRank = Values.EconomyRank.Value
local FirstClassName = Values.FirstClassName.Value
local FirstClassTicket = Values.FirstClassTicket
local FirstClassRank = Values.FirstClassRank.Value
local InvestorClassName = Values.InvestorClassName.Value
local InvestorClassTicket = Values.InvestorClassTicket
local InvestorRank = Values.InvestorRank.Value
local groupID = Values.groupID.Value
local Gui = script.Parent:WaitForChild("LoadingGUI")
local GuiClone = Gui:Clone()
GuiClone.Parent = game.ReplicatedStorage
local Brick = script.Parent.SCIParts.Touch
Brick.Touched:Connect(function(hit)
if debounce then
return
end
if hit.Parent:FindFirstChild("Humanoid") then
local Player = game.Players:GetPlayerFromCharacter(hit.Parent)
if Player then
debounce = true
local Gui = game.ReplicatedStorage:WaitForChild("LoadingGUI")
local GuiClone = Gui:Clone()
GuiClone.Parent = Player:WaitForChild("PlayerGui")
local rank = Player:GetRankInGroup(groupID)
Player:WaitForChild("Backpack")
local ticket = nil
if rank == EconomyRank then
ticket = ReplicatedStorage:WaitForChild(EconomyClassTicket.Value)
elseif rank == BusinessRank then
ticket = ReplicatedStorage:WaitForChild(BusinessClassTicket.Value)
elseif Class3 == false then
if rank == FirstClassRank then
ticket = ReplicatedStorage:WaitForChild(FirstClassTicket.Value)
elseif rank >= InvestorRank then
ticket = ReplicatedStorage:WaitForChild(InvestorClassTicket.Value)
end
elseif rank >= FirstClassRank then
ticket = ReplicatedStorage:WaitForChild(FirstClassTicket.Value)
end
if ticket then
local alreadyHasTicket = Player.Backpack:FindFirstChild( ticket.Name ) or Player.Character:FindFirstChild( ticket.Name )
if not alreadyHasTicket then
ticket:Clone().Parent = Player.Backpack
end
end
wait(5)
debounce = false
end
end
end)
You can use tables for debounces on server scripts. This is an example:
local playerDebounces = {}
local function enableObject(player)
if not playerDebounces[player] then
playerDebounces[player] = true
wait(3)
playerDebounces[player] = false
end
end
Do you mean stop appearing in studio or in game? I belive you can use debounce. In studio, on the top right there is an “eye” icon, click it and it should go away.
You will have to change ToolName as your tool name, name. Here is how it should look like:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local debounce = false
local Values = script.Parent.Values
local BusinessClassName = Values.BusinessClassName.Value
local BusinessClassTicket = Values.BusinessClassTicket
local BusinessRank = Values.BusinessRank.Value
local Class3 = Values.Class3.Value
local EconomyClassName = Values.EconomyClassName.Value
local EconomyClassTicket = Values.EconomyClassTicket
local EconomyRank = Values.EconomyRank.Value
local FirstClassName = Values.FirstClassName.Value
local FirstClassTicket = Values.FirstClassTicket
local FirstClassRank = Values.FirstClassRank.Value
local InvestorClassName = Values.InvestorClassName.Value
local InvestorClassTicket = Values.InvestorClassTicket
local InvestorRank = Values.InvestorRank.Value
local groupID = Values.groupID.Value
local Gui = script.Parent:WaitForChild("LoadingGUI")
local GuiClone = Gui:Clone()
GuiClone.Parent = game.ReplicatedStorage
local Brick = script.Parent.SCIParts.Touch
Brick.Touched:Connect(function(hit)
if debounce then
return
end
if hit.Parent:FindFirstChild("Humanoid") then
local Player = game.Players:GetPlayerFromCharacter(hit.Parent)
if Player and not game:GetService("Players"):FindFirstChild(hit.Parent.Name).Backpack:FindFirstChild("ToolName") then --Change here your tool name
debounce = true
local Gui = game.ReplicatedStorage:WaitForChild("LoadingGUI")
local GuiClone = Gui:Clone()
GuiClone.Parent = Player:WaitForChild("PlayerGui")
local rank = Player:GetRankInGroup(groupID)
Player:WaitForChild("Backpack")
local ticket = nil
if rank == EconomyRank then
ticket = ReplicatedStorage:WaitForChild(EconomyClassTicket.Value)
elseif rank == BusinessRank then
ticket = ReplicatedStorage:WaitForChild(BusinessClassTicket.Value)
elseif Class3 == false then
if rank == FirstClassRank then
ticket = ReplicatedStorage:WaitForChild(FirstClassTicket.Value)
elseif rank >= InvestorRank then
ticket = ReplicatedStorage:WaitForChild(InvestorClassTicket.Value)
end
elseif rank >= FirstClassRank then
ticket = ReplicatedStorage:WaitForChild(FirstClassTicket.Value)
end
if ticket then
local alreadyHasTicket = Player.Backpack:FindFirstChild( ticket.Name ) or Player.Character:FindFirstChild( ticket.Name )
if not alreadyHasTicket then
ticket:Clone().Parent = Player.Backpack
end
end
wait(5)
debounce = false
end
end
end)
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Values = script.Parent.Values
local BusinessClassName = Values.BusinessClassName.Value
local BusinessClassTicket = Values.BusinessClassTicket
local BusinessRank = Values.BusinessRank.Value
local Class3 = Values.Class3.Value
local EconomyClassName = Values.EconomyClassName.Value
local EconomyClassTicket = Values.EconomyClassTicket
local EconomyRank = Values.EconomyRank.Value
local FirstClassName = Values.FirstClassName.Value
local FirstClassTicket = Values.FirstClassTicket
local FirstClassRank = Values.FirstClassRank.Value
local InvestorClassName = Values.InvestorClassName.Value
local InvestorClassTicket = Values.InvestorClassTicket
local InvestorRank = Values.InvestorRank.Value
local groupID = Values.groupID.Value
local Gui = script.Parent:WaitForChild("LoadingGUI")
local GuiClone = Gui:Clone()
GuiClone.Parent = game.ReplicatedStorage
local Brick = script.Parent.SCIParts.Touch
Brick.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local Player = game.Players:GetPlayerFromCharacter(hit.Parent)
if Player and not game:GetService("Players"):FindFirstChild(hit.Parent.Name).Backpack:FindFirstChild("Economy Class Ticket") and game:GetService("Players"):FindFirstChild(hit.Parent.Name).Backpack:FindFirstChild("Business Class Ticket") and game:GetService("Players"):FindFirstChild(hit.Parent.Name).Backpack:FindFirstChild("First Class Ticket") and game:GetService("Players"):FindFirstChild(hit.Parent.Name).Backpack:FindFirstChild("Investor Class Ticket ")
local Gui = game.ReplicatedStorage:WaitForChild("LoadingGUI")
local GuiClone = Gui:Clone()
GuiClone.Parent = Player:WaitForChild("PlayerGui")
local rank = Player:GetRankInGroup(groupID)
Player:WaitForChild("Backpack")
local ticket = nil
if rank == EconomyRank then
ticket = ReplicatedStorage:WaitForChild(EconomyClassTicket.Value)
elseif rank == BusinessRank then
ticket = ReplicatedStorage:WaitForChild(BusinessClassTicket.Value)
elseif Class3 == false then
if rank == FirstClassRank then
ticket = ReplicatedStorage:WaitForChild(FirstClassTicket.Value)
elseif rank >= InvestorRank then
ticket = ReplicatedStorage:WaitForChild(InvestorClassTicket.Value)
end
elseif rank >= FirstClassRank then
ticket = ReplicatedStorage:WaitForChild(FirstClassTicket.Value)
end
if ticket then
local alreadyHasTicket = Player.Backpack:FindFirstChild( ticket.Name ) or Player.Character:FindFirstChild( ticket.Name )
if not alreadyHasTicket then
ticket:Clone().Parent = Player.Backpack
end
end
end
end
You forgot to add “not” next to “and”. Make sure that there is no any whitespaces if your tool doesn’t have it either inside of a string you are checking.
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Values = script.Parent.Values
local BusinessClassName = Values.BusinessClassName.Value
local BusinessClassTicket = Values.BusinessClassTicket
local BusinessRank = Values.BusinessRank.Value
local Class3 = Values.Class3.Value
local EconomyClassName = Values.EconomyClassName.Value
local EconomyClassTicket = Values.EconomyClassTicket
local EconomyRank = Values.EconomyRank.Value
local FirstClassName = Values.FirstClassName.Value
local FirstClassTicket = Values.FirstClassTicket
local FirstClassRank = Values.FirstClassRank.Value
local InvestorClassName = Values.InvestorClassName.Value
local InvestorClassTicket = Values.InvestorClassTicket
local InvestorRank = Values.InvestorRank.Value
local groupID = Values.groupID.Value
local Gui = script.Parent:WaitForChild("LoadingGUI")
local GuiClone = Gui:Clone()
GuiClone.Parent = game.ReplicatedStorage
local Brick = script.Parent.SCIParts.Touch
Brick.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local Player = game.Players:GetPlayerFromCharacter(hit.Parent)
if Player and not game:GetService("Players"):FindFirstChild(hit.Parent.Name).Backpack:FindFirstChild("Economy Class Ticket") and not game:GetService("Players"):FindFirstChild(hit.Parent.Name).Backpack:FindFirstChild("Business Class Ticket") and not game:GetService("Players"):FindFirstChild(hit.Parent.Name).Backpack:FindFirstChild("First Class Ticket") and not game:GetService("Players"):FindFirstChild(hit.Parent.Name).Backpack:FindFirstChild("Investor Class Ticket") then
local Gui = game.ReplicatedStorage:WaitForChild("LoadingGUI")
local GuiClone = Gui:Clone()
GuiClone.Parent = Player:WaitForChild("PlayerGui")
local rank = Player:GetRankInGroup(groupID)
Player:WaitForChild("Backpack")
local ticket = nil
if rank == EconomyRank then
ticket = ReplicatedStorage:WaitForChild(EconomyClassTicket.Value)
elseif rank == BusinessRank then
ticket = ReplicatedStorage:WaitForChild(BusinessClassTicket.Value)
elseif Class3 == false then
if rank == FirstClassRank then
ticket = ReplicatedStorage:WaitForChild(FirstClassTicket.Value)
elseif rank >= InvestorRank then
ticket = ReplicatedStorage:WaitForChild(InvestorClassTicket.Value)
end
elseif rank >= FirstClassRank then
ticket = ReplicatedStorage:WaitForChild(FirstClassTicket.Value)
end
if ticket then
local alreadyHasTicket = Player.Backpack:FindFirstChild( ticket.Name ) or Player.Character:FindFirstChild( ticket.Name )
if not alreadyHasTicket then
ticket:Clone().Parent = Player.Backpack
end
end
end
end
Im confused. What do you mean by “Make sure that there is no any whitespaces if your tool doesn’t have it either inside of a string you are checking.”