-- [[ Variable Storage ]] --
local CommonTrigger = game.Workspace:FindFirstChild("CommonTrigger")
-- [[ Code ]] --
game.Players.PlayerAdded:connect(function(Player)
local DebounceValue = Instance.new("BoolValue", Player)
DebounceValue.Name = "DebounceValue"
DebounceValue.Value = false
end)
function onTouched(hit)
local Humanoid = hit.Parent:FindFirstChild("Humanoid")
local Player = Players:GetPlayerFromCharacter(hit.Parent)
if Player.DebounceValue.Value == false then
Player.DebounceValue.Value = true
Humanoid.WalkSpeed = 0
local CommonUI = ReplicatedStorage:FindFirstChild("PT_UI").CommonUI:Clone()
CommonUI.Parent = Player.PlayerGui
CommonUI.Frame:TweenPosition(UDim2.new(0.5,-350,0.5,-200), "Out", "Elastic", 3)
end
end
CommonTrigger.Touched:connect(onTouched)
The point of this script is to give every player a DebounceValue once they join the game. If they touch a certain brick, then a UI will slide down.
Now everything works fine and dandy EXCEPT my debounce method. If they touch the brick, it gives them like five of the same GUI, even with the debounce.
Before you ask why I did a BoolValue for Debounce, I honestly forgot why, but if you want to improve it or get rid of it, feel free.
Answers would be greatly appreciated!
