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

Press Shift to run doesnt work!?

Asked by
Jurdy 0
10 years ago
player = game.Players.LocalPlayer
mouse = player:GetMouse()

mouse.KeyDown:connect(function(key)
if key == "48" then
player.Character.Humanoid.WalkSpeed = 25
    end
end)

mouse.KeyUp:connect(function(key)
if key == "48" then
player.Character.Humanoid.WalkSpeed = 16
    end
end)

--doesnt work, please help!
0
Put the localscript into 'StarterGui' and make the script a localscript. MessorAdmin 598 — 10y

3 answers

Log in to vote
1
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
10 years ago

I don't see anything in particular wrong with your script thare, except maybe efficiency.. but here's another method for doing this. Using UserInputService, with the InputBegan, and InputEnded event will work as well, if not better.

Example;

local input = game:GetService("UserInputService")
local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse()

input.InputBegan:connect(function(key)
    if key == Enum.KeyCode.LeftShift then
        plr.Character.Humanoid.WalkSpeed = 36
    end
end)

input.InputEnded:conect(function(key)
    if key == Enum.KeyCode.LeftShift then
        plr.Character.Humanoid.WalkSpeed = 16
    end
end)
0
I know this is very old but thanks, this helped me out a lot j_osephx 3 — 4y
0
You are welcome, I hope you are still learning becoming better! Happy developing! Goulstem 8144 — 4y
Ad
Log in to vote
0
Answered by
Tkdriverx 514 Moderation Voter
10 years ago

You need to convert key to a byte.

key = key:byte()

You also need to change the strings to just numbers. Or you can use UserInputService (see other answer by Goulstem)

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

-- Put In StarterGui -- By JasonkaranikYoutube

local player = game.Players.LocalPlayer 
local mouse = player:GetMouse()

mouse.KeyDown:Connect(function(key)
    if key:lower() == string.char(48) then
        local hum = game.Players.LocalPlayer.Character.Humanoid
        if hum then
             hum.WalkSpeed = 500
        end
    end
end)

mouse.KeyUp:Connect(function(key)
    if key:lower() == string.char(48) then
        local hum = game.Players.LocalPlayer.Character.Humanoid
        if hum then
             hum.WalkSpeed = 16
        end
    end
end)

Answer this question