Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Does we use remote event to open gui using keybind?

Asked by 5 years ago

my local script

local plr = game:GetService("Players").LocalPlayer
local Mouse = plr:GetMouse() 
local cas = game:GetService("ContextActionService") 


local function onEPress(name, state, input)
    if state == Enum.UserInputState.Begin then
     game.ReplicatedStorage.RemoteEvent1:FireServer()
    end
   end

cas:BindAction("ePressed", onEPress, false, Enum.KeyCode.E) -- basically when E is pressed, onEPress runs.


My script

game.ReplicatedStorage.RemoteEvent1.OnServerEvent:Connect(function()
    -- Any code in here will run when RemoteEvent is triggered
    script.Parent.Transparency = 0.5
end)

0
No need, if you only want the player to see the gui. xxXTimeXxx 101 — 5y
0
No User#19524 175 — 5y
0
well how do you do it then? RainbowBeastYT 85 — 5y
0
do I use this ``local function onQPress(name, state, input) if state == Enum.UserInputState.Begin then script.Parent.Frame.Visible = true`` RainbowBeastYT 85 — 5y

2 answers

Log in to vote
1
Answered by 5 years ago

Hello RainbowBeastYT, you do not need remote event to open gui. The server should not have to know of this let alone handle gui. It's good to do it on the local script and there only because it causes less lag. Unless if you press the button all players should see it but that will be annoying to the players that try playing your game.

local plr = game:GetService("Players").LocalPlayer
local Mouse = plr:GetMouse() 
local cas = game:GetService("ContextActionService") 


local function onEPress(name, state, input)
    if state == Enum.UserInputState.Begin then
     script.Parent.BackgroundTransparency = 0.5
    end
   end

cas:BindAction("ePressed", onEPress, false, Enum.KeyCode.E) -- basically when E is pressed, onEPress runs.
Ad
Log in to vote
0
Answered by 5 years ago

Hello,

--Start
function doStuff()
    --insert code you want to do here
end
game:GetService("ContextActionService"):BindAction("ExecuteCode", doStuff, false, "f") --if F is pressed it will run the doStuff()
--End

~Frag

0
!IMPORTANT! this needs to be a local script on StarterPlayerScripts. Fragmentation123 226 — 5y
0
This is not answering the question. User#23407 5 — 5y
0
^ User#19524 175 — 5y
0
I know I gave him a template. Fragmentation123 226 — 5y
0
What week is saying is that you didn't answer OP's question. OP asked if you use remotes to open a GUI. You did not answer this in any way. Please stop with the low quality answers. User#19524 175 — 5y

Answer this question