How do I get my gui to not glitch out or disappear when being tweened when a player spams a key instead of waiting for the tween to finish?
--
wait(0.3)
--
local PlayerService = game:GetService("Players")
local player = game.Players.LocalPlayer.Character
local Backpack = game.Players.LocalPlayer.Backpack
local hum = player.Humanoid
--
local weapon = script.Parent.Weapon
local item = script.Parent.Item
local clothes = script.Parent["?"]
local equiped = script.Parent.Equiped
local wepinv = script.Parent["Weapon.Inv"]
local iteminv = script.Parent["Item.Inv"]
local invtitle = script.Parent["Inv.Title"]
local equiptitle = script.Parent["Equipped.Title"]
inv = false
--
uis = game:GetService("UserInputService")
plr = game.Players.LocalPlayer
--
uis.InputBegan:connect(function(input)
if input.KeyCode == Enum.KeyCode.B and inv == false
then
weapon:TweenPosition(UDim2.new( 0, 150, 0, 210), 'InOut', 'Sine', 1.5)
item:TweenPosition(UDim2.new( 0, 360, 0, 210), 'InOut', 'Sine', 1.5)
clothes:TweenPosition(UDim2.new( 0, 570, 0, 210), 'InOut', 'Sine', 1.5)
equiped:TweenPosition(UDim2.new( 0, 780, 0, 210), 'InOut', 'Sine', 1.5)
wepinv:TweenPosition(UDim2.new( 0, 150, 0, 310), 'InOut', 'Sine', 1.5)
iteminv:TweenPosition(UDim2.new( 0, 150, 0, 310), 'InOut', 'Sine', 1.5)
invtitle:TweenPosition(UDim2.new( 0, 150, 0, 80), 'InOut', 'Sine', 1.5)
equiptitle:TweenPosition(UDim2.new( 0, 780, 0, 80), 'InOut', 'Sine', 1.5)
inv = true
end
end)
uis.InputBegan:connect(function(input)
if input.KeyCode == Enum.KeyCode.B and inv == true
then
weapon:TweenPosition(UDim2.new( -1, 150, 0, 210), 'InOut', 'Sine', 1.5)
item:TweenPosition(UDim2.new( -1, 360, 0, 210), 'InOut', 'Sine', 1.5)
clothes:TweenPosition(UDim2.new( -1, 570, 0, 210), 'InOut', 'Sine', 1.5)
equiped:TweenPosition(UDim2.new( -1, 780, 0, 210), 'InOut', 'Sine', 1.5)
wepinv:TweenPosition(UDim2.new( -1, 150, 0, 310), 'InOut', 'Sine', 1.5)
iteminv:TweenPosition(UDim2.new( -1, 150, 0, 310), 'InOut', 'Sine', 1.5)
invtitle:TweenPosition(UDim2.new( -1, 150, 0, 80), 'InOut', 'Sine', 1.5)
equiptitle:TweenPosition(UDim2.new( -1, 780, 0, 80), 'InOut', 'Sine', 1.5)
inv = false
end
end)

2 comments
Yeah, I've got the tweening part done, but if the player presses the key before the tween finishes it glitches out.
The thing is, as seen in your script, you're using :TweenPosition instead of the TweenService method I suggested above.