I made this script
local guinamehere = Workspace.guinamehere local player = game.Players.LocalPlayer
script.Parent.(Key:lower() == "e") then:connect(function() guinamehere:Clone().Parent = player.PlayerGui end)
it wont work. can somebody help me?
I made this script
local guinamehere = Workspace.guinamehere local player = game.Players.LocalPlayer
script.Parent.(Key:lower() == "e") then:connect(function() guinamehere:Clone().Parent = player.PlayerGui end)
it wont work. can somebody help me?
Use the ContextActionService or the UserInputService.
Looking at your code, you attempted a Mouse.KeyDown event, that is deprecated. Do not use it for new work.
And yes a LocalScript. The LocalScripts are on clients, and they handle user input, not the server.
If you used a server script to do this, it:
#1. Has to tell the server you pressed a button #2. The server tells your client to show the Gui #3. Lots of lag
But with a LocalScript you can simply press a button, and simply make the gui appear and completely eliminate lag time.
-- ContextActionService method
--Make sure that the Gui is in StarterGui, but the frame's Visible property is set to false.
--LocalScript inside of your ScreenGui.
function showGui()
script.Parent.Frame.Visible = not script.Parent.Frame.Visible
end
game:GetService("ContextActionService"):BindAction("ShowGui", -- action name
showGui, -- function bound
false, -- create touch button which appears for only mobile players
Enum.KeyCode.B, -- variable amount of user input to make the function fire
Enum.KeyCode.E
)
UserInputService method
-- Same thing. In a LocalScript inside the ScreenGui.
-- UserInputService method
local UIS = game:GetService"UserInputService"
function showGui()
script.Parent.Frame.Visible = not script.Parent.Frame.Visible
end
UIS.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.B then
showGui()
end
end)
This discussion is preserved as it was. New answers, comments, and votes are closed.
3 comments
Needs to be in a code block...
whats a codeblock
https://scriptinghelpers.org/help/how-post-good-questions-answers