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

Using RemoteEvents with UserInputService? Client/Server Sided

Asked by 3 years ago
Edited 3 years ago

Its not like I dont know how to make UIS with RemoteEvents, But they don't work... Here is my code:

Client Script w/ UserInputService and RemoteEvent

local RE = game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvent")
local UIS = game:GetService("UserInputService")

UIS.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.B  then
RE:FireServer()
end
end)

Server Script:

local RE = game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvent")
RE.OnServerEvent:Connect(function()
print("Success")
end)

But the UIS does not React to That. That's why In my First Post, I used the :GetMouse Method

1 answer

Log in to vote
1
Answered by 3 years ago
Edited 3 years ago

Put the local script somewhere that resides within the client/player — Like StarterPlayerScripts. Put the server script somewhere that resides within the server — Like Workspace.

Ad

Answer this question