Hello I am Tyrums. A Roblox builder learning how to script something for a game. I want to find a way to give 1 player a gui after a certain amount of time and the only way for it to dissapear is for the player to press 2-3 buttons (Basically like a Apu panel I guess) and then it dissapears How would I be able to do such a think and is there a proper way to do that?
Use PlayerAdded function and Enum.Keycode (search on developer wiki)
Could you explain what a Player Added function is?
It’s check if player joined game or not
game.Players.PlayerAdded:Connect (function()
end)
You can do all this on the client, no need for PlayerAdded on the server.
Just create a local script and a GUI of your choice, put it under the script and use follow these steps:
- Create a couple of tables, one empty and one containing all the possible keys the player can press (defined with Enum.KeyCode.Key)
- Create a function that clones the Gui you made, put it in the PlayerGui and chooses random keys from the table you’ve made before. Put the keys in the empty table from before (which I’ll call “A”)
- Detect when a player presses a key with UserInputService.InputBegan
- If the key is found in A then remove the key from it
- If nothing is found in A, destroy the gui
Is there a way to do multiple buttons before it dissapears like more than 2?
Its simple, first for keybinds use UserInputService
local UIS = game:GetService:("UserInputService")
UIS.InputBegan:Connect(function(key)
if key.KeyCode == Enum.KeyCode.YourKey then
print("Player pressed" .. key .. "!")
end
end)
Oh No I meant like GUI Buttons not letters but buttons on the gui.
Yes, you can use TextButtons and detect a left mouse button click with MouseButton1Click (or right with MouseButton2Click)
Alright now then we can do multiple of those buttons and when the right buttons are pressed it destroys the panel?
Hello, I’m back and I found out a way to do what I was looking for it uses values to determine wether or not the button is clicked right here is a part of the script that just duplicates for all of them.
if Script.parent.frame.button1.Value.Value==1 then
script.parent.frame.button1.Value.Value=0
elseif Script.parent.frame.button1.Value.Value==0 then
Script.parent.frame.button1.Value.Value=1
(Basic Switch value script i guess.)
then it detects wether or not it is depending on wether its on the right value it will destroy for example:
if Script.parent.frame.button1.Value.Value=1 then
script.parent.frame:Destroy()
That is a way to do it. You might like a shorter way of doing it too, using booleans instead of values,
local button1Switch = false -- (outside of event)
.
.
.
-- (inside of event)
if button1Switch == true then
button1Switch = false
elseif button1Switch == false then
button1Switch = true
end
Something like this might be easier to edit in the future
Great I’ll look into it thanks for the help