Hi there, ok so i have a custom player list I have made and I want a “Tab” toggle to tween the the player list off the screen and then put it back if pressed again. I know this topic is already discuss by @Thestralance but i really confuse on how he do it. I hope u guys can teach me how to, thanks.
Here is the necessary code for what I think you are trying to accomplish.
Let me know what error there is.
local UIS = game:GetService('UserInputService')
UIS.InputBegan:Connect(function(key))
if key.KeyCode == Enum.KeyCode.Tab then
if isEnabled then
-- put tween service thingy here for going invisible
isEnabled = false
else
isEnabled = true
-- put tween service here for going visible
end
end
end)
Let me know if this worked or not, I am on a trash computer so I cant test!
ok thx but where do i need to put the code?
You gotta create the script as a child in the screengui of the tab list
By the way, if you believe my reply is the solution, u can hit that checkmark button somewhere on my reply.
under my reply there is a button that says solution, press it!
Use Enum.KeyCode.Tab
and a function to check if that key has been clicked.
Here’s an example code:
local ContextActionService = game:GetService('ContextActionService')
function action(name, state, obj)
if state == Enum.UserInputState.Begin then
print('tab key was clicked')
end
end
ContextActionService:BindAction('tabTween', action, false, Enum.KeyCode.Tab)
(not sure if this works)
Edit: Also you’ll need to make it a LocalScript.
jeez, use userinputservice that will not work man.
i didnt test it but UIS is more simpler
I believe that what @smartabity1 said is the solution, but keep in mind that you can also use the ‘ContextActionService’ to bind the input to a function, it is more efficient than using the UserInputService for your use.
Read about it here: ContextActionService | Roblox Creator Documentation
never knew that existed, but ive been using UIS for over a year with no problem.
umm the code is not work
ill get back to u tomorrow i gtg,
ask the other amazing community
I’m pretty sure it works maybe not, as I stated I’m not sure if it works or not.
give me the error please.
i need the error, ill be working on it tomorrow or today
Oh, you’ll need to define a isEnabled
variable in your code.
im sorry but i dont really understand what you said cuz im new on scripting, sorry
You would basically change it to something like this, also when testing print if the thing has been opened or not so you can see if it works or not.
local UIS = game:GetService('UserInputService')
local isEnabled = false
UIS.InputBegan:Connect(function(key)
if key.KeyCode == Enum.KeyCode.Tab then
if isEnabled then
print('closed')
isEnabled = false
else
isEnabled = true
print('opened')
end
end
end)
it doesnt work i dont understand why
You’ll need to add stuff like TweenPosition
in order to tween the gui.
This probally wont work since I’m on mobile.
local UIS = game:GetService('UserInputService')
local isEnabled = false
local frame = script.Parent
local yPos = frame.Position.Y.Scale
local xPos = frame.Position.X.Scale
UIS.InputBegan:Connect(function(key)
if key.KeyCode == Enum.KeyCode.Tab then
if isEnabled then
print('closed')
isEnabled = false
frame:TweenPosition(
UDim2.new(-1, 0, yPos, 0),
'Out',
'Linear',
.34,
true
)
else
isEnabled = true
print('opened')
frame:TweenPosition(
UDim2.new(xPos, 0, yPos, 0),
'Out',
'Linear',
.34,
true
)
end
end
end)