Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

What do I write to have a player respond in a certain way at the push of a button on the keyboard?

Im a very basic scripter who is stumbled by the simplest things. Help would be nice.

2 answers

This requires a LocalScript:

player=Game.Players.LocalPlayer
mouse=player:GetMouse()

mouse.KeyDown:connect(function(key) --key being the key they pressed
print(key)
end)

--In less complicated terms if not familiar with anonymous functions(place in a local script): Player = game.Players.LocalPlayer Mouse = Player:GetMouse()

function onKeyDown(key)
	key = key:lower() -- this enables the script to work even if your in capslock
	if key == "z" then
		Player:BreakJoints() -- change this to whatever
	end
end

Mouse.KeyDown:connect(onKeyDown)

This discussion is preserved as it was. New answers, comments, and votes are closed.