Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Having a hard time making a pause gui, help?

All of the other localscripts I use userinputservice with work online, but this one specifically doesn't and only works in studio.

local k = script.Parent:WaitForChild("PauseMenuGuiEnabler")

function onKeyPress(inputObject, gameProcessedEvent)
	k.Value = k.Value + 1
if inputObject.KeyCode == Enum.KeyCode.Tab then
		
print("k.value")
		end
	end



game:GetService("UserInputService").InputBegan:connect(onKeyPress)




3 comments

0

What is the script's Parent?

0

@Goulstem The parent is StarterGui

0

What about it doesn't work? If you want it to print the value, get rid of the Quotations, as it is just a string right now.

1 answer

You don't need to call a function, you can just make UserInputService a variable, I will be Editing and I did manage to find a problem.

Here's the edited script explaining;

local k = script.Parent:WaitForChild("PauseMenuGuiEnabler")
local uis = game:GetService('UserInputService') -- the variable

uis.InputBegan:Connect(function(input) -- we use connect with a  cap C, lower case connect is deprecated!
	k.Value = k.Value + 1
	if input.KeyCode = Enum.KeyCode.Tab then
		print("k.value")
	end
end)

Now what you do is place this Local Script Inside of StarterPlayerScripts which you can find if you scroll down in explorer.

If you did exactly what I did and what I listed, by pressing Tab k.Value should be added. Just make sure this is in StarterPlayerScripts

If this helped then please accept answer ;)

Good luck and have fun developing!

This discussion is preserved as it was. New answers, comments, and votes are closed.