On a Local Script:
player = game.Players.LocalPlayer:GetMouse() player.KeyDown:connect(function(key) if key == "r" then Instance.new("Part", game.Workspace) end 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.
game:GetService('UserInputService').InputBegan:Connect(function(input, processed) if input.KeyCode == Enum.KeyCode.E then processed = true game.ReplicatedStorage.KeyPressed:FireAllClients() end end)
game.ReplicatedStorage.KeyPressed.OnClientEvent:Connect(function() local part = Instance.new('Part', workspace) end)
To detect for a keyboard key press you could use this:
function onKeyPress(inputObject, gameProcessedEvent) if inputObject.KeyCode == Enum.KeyCode.R then print("R was pressed") Instance.new("Part", game.Workspace) end end game:GetService("UserInputService").InputBegan:Connect(onKeyPress)
Sorry for the poor indentation of this code.
Hope this helps,
Tweakified