✓ Accepted answer
Sadly, this is for a keyboard key input. But, maybe it'll help.
- Add a RemoteEvent to game.ReplicatedStorage
- Name the event 'KeyPressed'
- Go to StarterPlayer > StarterPlayerScripts
- Right-click StarterPlayerScripts
- Hover 'Insert Object'
- Click 'Local Script'
- (Code): Type:
game:GetService('UserInputService').InputBegan:Connect(function(input, processed)
if input.KeyCode == Enum.KeyCode.E then
processed = true
game.ReplicatedStorage.KeyPressed:FireAllClients()
end
end)
- Add a script (Server script) to game.ServerScriptService
- Enter the script and type: (code):
game.ReplicatedStorage.KeyPressed.OnClientEvent:Connect(function()
local part = Instance.new('Part', workspace)
end)
1 comment
You need to call the server on the client (and you can't fire all clients directly on the client anyways) and use OnServerEvent on the server.