Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

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

Asked by 10 years ago

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

2 answers

Log in to vote
0
Answered by 10 years ago

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)
Ad
Log in to vote
0
Answered by
LevelKap 114
10 years ago

--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)

Answer this question