Player = game.Players.LocalPlayer gui = script.Parent Mouse = Player:GetMouse() Box = script.Parent Open = false game.GetService("UserInputService").InputBegan:Connect(function(key) if key.Keycode == Enum.Keycode.R then if (Open == false) then Box.Transparency = 0 Open = true elseif (Open == true) then Box.Transparency = 1 Open = false end end end)
This is the code I have made. Whenever I press R nothing happens. Not sure what I did wrong.
Lol a simple mistake on your part contributed to your code not working.
if key.Keycode == Enum.Keycode.R then
should be
if key.KeyCode == Enum.KeyCode.R then
You should have gotten errors a bit like
10:03:12.857 - Keycode is not a valid member of InputObject
To figure out the correct ways to do this look here https://developer.roblox.com/en-us/api-reference/class/InputObject