On a Local Script:
01 | player = game.Players.LocalPlayer:GetMouse() |
02 |
03 | player.KeyDown:connect( function (key) |
04 |
05 |
06 |
07 | if key = = "r" then |
08 |
09 |
10 |
11 |
12 |
13 |
14 | Instance.new( "Part" , game.Workspace) |
15 |
16 | end |
17 |
18 |
19 | end ) |
But this does not help me because i want to all can see it.
I want to do it on a script to all can see it.
Sadly, this is for a keyboard key input. But, maybe it'll help.
1 | game:GetService( 'UserInputService' ).InputBegan:Connect( function (input, processed) |
2 | if input.KeyCode = = Enum.KeyCode.E then |
3 | processed = true |
4 | game.ReplicatedStorage.KeyPressed:FireAllClients() |
5 | end |
6 | end ) |
1 | game.ReplicatedStorage.KeyPressed.OnClientEvent:Connect( function () |
2 | local part = Instance.new( 'Part' , workspace) |
3 | end ) |
To detect for a keyboard key press you could use this:
1 | function onKeyPress(inputObject, gameProcessedEvent) |
2 | if inputObject.KeyCode = = Enum.KeyCode.R then |
3 | print ( "R was pressed" ) |
4 | Instance.new( "Part" , game.Workspace) |
5 | end |
6 | end |
7 |
8 | game:GetService( "UserInputService" ).InputBegan:Connect(onKeyPress) |
Sorry for the poor indentation of this code.
Hope this helps,
Tweakified