I am using a script for a group game, and I was wondering how I add a custom keybind to it. For example, when you press b the script activates.
COMMUNITY QUESTION
How do you make a key bind for a custom script?
1 answer
You could use remote events.
For example...
Script1, ServerScriptService
game.Players.PlayerAdded:Connect(function()
game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(player)
Instance.new("Part", workspace)
end)
end)
Script2 (local script) , Starterpack
local player = game.Players.LocalPlayer
local REvent = game.ReplicatedStorage.RemoteEvent
local mouse = player:GetMouse()
mouse.KeyDown:connect(function(key)
if key == "z" then
REvent:FireServer()
end
end)
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
I think you need to learn more.
playlist--> https://www.youtube.com/watch?v=BkYwRdCukZA&list=PLhieaQmOk7nIfMZ1UmvKGPrwuwQVwAvFa it's a good (in my opinion) YouTuber that teaches scripting