as the title said, how do i check if a specific player presses a key? Ive tried to do
local cool = {"Cill_Roblox"} local gui = script.Parent game.Players.PlayerAdded:Connect(function(player) if player.Name == cool then if game:GetService("UserInputService"):IsKeyDown(Enum.KeyCode.L) then gui.Enabled = true end end end)
but that doesnt work since playeradded only checks once as far as i know and
local cool = {"Cill_Roblox"} local gui = script.Parent local guy = false local uis = game:GetService("UserInputService") game.Players.PlayerAdded:Connect(function(player) if player.Name == cool then guy = true end end) uis.InputBegan:Connect(function(input, gameProccesedEvent) if input.UserInputType == Enum.KeyCode.L then if guy == true then gui.Enabled = true end end end)
ive tried looking stuff like "how to check if specific player presses a key roblox" but found nothing on this so far. anyone know something about this? any help is appreciated
first of all, you need to make sure that the UserInputService part is in a local script as it's client-side only, second of all, try using the InputBegan event to toggle the gui instead of checking if a key is being held down.
example:
gui = script.Parent userInputService = game:GetService("UserInputService") userInputService.InputBegan:Connect(function(input, gameProcessed) if input.KeyCode == Enum.KeyCode.L and game.Players.LocalPlayer.DisplayName == "Cill_Roblox" then gui.Enabled = true end)