Part.Touched:Connect(function(hit) local Hit = hit.Parent:FindFirstChild("Humanoid") if Hit then local player = game.Players:GetPlayerFromCharacter(hit.Parent) if player then if player.OtherInfo.Backpack.Value < player.OtherInfo.MaxBackpack.Value then Gui:TweenPosition( UDim2.new(0.25, 0,0.01, 0), "Out", "Sine", .5, false ) wait(5) end end end end)
I have tried this but it doesn't work. What I want to do is when the player touches a part it drops down a gui but when they close and go of the part then it opens again because it detects the player touching it. Does anyone know how to fix this?
You should use a boolean debounce.
local HasbeenTouched = false -- Your debounce Part.Touched:Connect(function(hit) local Hit = hit.Parent:FindFirstChild("Humanoid") if Hit then local player = game.Players:GetPlayerFromCharacter(hit.Parent) if player then if player.OtherInfo.Backpack.Value < player.OtherInfo.MaxBackpack.Value then if HasbeenTouched == false then HasbeenTouched = true Gui:TweenPosition( UDim2.new(0.25, 0,0.01, 0), "Out", "Sine", .5, false ) wait(5) HasbeenTouched = false end end end end end)