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

Why is my shift to sprint script not making my character run?

Asked by
wookey12 174
7 years ago

I tried all i could to find n error, but i couldn't. Even the output said nothing.

-- Made by wookey12 :)
wait(1)
local player = game.Players.LocalPlayer
local mouse = game.Players.LocalPlayer:GetMouse()

mouse.KeyDown:Connect(function(KeyDown)
    if KeyDown == 48 then
        game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 30
    end
end)

mouse.KeyUp:Connect(function(KeyUp)
    if KeyUp == 48 then
        player.Character.Humanoid.WalkSpeed = 16
    end
end)
0
KeyDown is deprecated. Shawnyg 4330 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago

First of all, try to make ":Connect" into ":connect", and maybe that will help.

Second of all, use

if KeyDown:byte() == 19 then

on those things instead of

if KeyDown == 19 then

It seems to work for me, I used a script in a game I'm making with that sort of idea:

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

function onkeyDown(key)
    if key:byte() == 19 then
        if script.Parent.CurrentOption.Value == "Fight" then
            script.Parent.CurrentOption.Value = "Act"
            script.Parent.Fight.Image = "rbxgameasset://Images/spr_fightbt_center_0"
            script.Parent.Act.Image = "rbxgameasset://Images/spr_actbt_center_1"
            script.Parent.Act.Heart.Visible = true
            script.Parent.Fight.Heart.Visible = false
        elseif script.Parent.CurrentOption.Value == "Act" then
            script.Parent.CurrentOption.Value = "Item"
            script.Parent.Act.Image = "rbxgameasset://Images/spr_actbt_center_0"
            script.Parent.Item.Image = "rbxgameasset://Images/spr_itembt_1"
            script.Parent.Item.Heart.Visible = true
            script.Parent.Act.Heart.Visible = false
        elseif script.Parent.CurrentOption.Value == "Item" then
            script.Parent.CurrentOption.Value = "Mercy"
            script.Parent.Item.Image = "rbxgameasset://Images/spr_itembt_0"
            script.Parent.Mercy.Image = "rbxgameasset://Images/spr_sparebt_1"
            script.Parent.Mercy.Heart.Visible = true
            script.Parent.Item.Heart.Visible = false
        elseif script.Parent.CurrentOption.Value == "Mercy" then
            script.Parent.CurrentOption.Value = "Fight"
            script.Parent.Mercy.Image = "rbxgameasset://Images/spr_sparebt_0"
            script.Parent.Fight.Image = "rbxgameasset://Images/spr_fightbt_center_1"
            script.Parent.Fight.Heart.Visible = true
            script.Parent.Mercy.Heart.Visible = false
        end
    end 
end

mouse.KeyDown:connect(onkeyDown)
0
Please gimme some points c; TheChampOfKillers 45 — 7y
0
I refuse to give you points since you didn't exactly point him in the proper direction. KeyDown is deprecated. Shawnyg 4330 — 7y
0
Thanks! Worked like a charm! wookey12 174 — 7y
0
Well I still used it anyways... I don't know how to use the other way that well xD TheChampOfKillers 45 — 7y
0
You can use :connect, but it's deprecated. Use :Connect Troidit 253 — 7y
Ad

Answer this question