Hi all, I've recently made a script for a keybind Gui appearance. For some reason some times when I PlayTest it doesnt do anything.
- Like 50% of the time it doesn't work when I press M right after I PlayTest.
The script is in a local script, I dont know if this is crucial information.
local Travel = script.Parent.Parent.Travel
p = game.Players.LocalPlayer
mouse = p:GetMouse()
local CanPress = true
mouse.KeyDown:connect(function(key)
if not CanPress then
return
end
CanPress = false
if key == "m" then
if Travel.Visible == true then
Travel:TweenPosition(
UDim2.new(-0.25, 0, 0.92, 0), --End Position
"Out", -- Easing Direction
"Quint", --Easing Style
2, --How Long Does It Take?
false --Other Tween Override
)
wait(2)
Travel.Visible = false
elseif Travel.Visible == false then
Travel.Visible = true
Travel:TweenPosition(
UDim2.new(0.01, 0, 0.92, 0),
"Out",
"Quint",
2,
false
)
end
CanPress = true
end
end)
Also I've been trying for SO LONG for it to accept my question!!

1 comment
mouse.KeyDown is deprecated. Use UserInputService instead.