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

Why does my localscript not run? [Air Walk LocalScript]

Asked by 1 year ago

so, ive been trying to make an ability where you can walk on air, and you press c to rise up and x to descend (go down). so i made a script like this, but it dosent even run. Like in the output, you can see print() is never executed.

local uis = game:GetService("UserInputService")
local airpad = Instance.new("Part", game.Workspace)
while true do
    wait()
    airpad.Position = game.Players.LocalPlayer.Character.Torso.Position
    airpad.Parent += Vector3.new(0,0,-5)
    uis.InputBegan:Connect(function(input, _gameproccesed)
        if input.UserInputType == Enum.KeyCode.C then
            local bv = Instance.new("BodyVelocity", airpad)
            bv.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
            bv.Velocity = Vector3.new(0,0,6)
            wait(2)
            bv:Destroy()
        end
        if input.UserInputType == Enum.KeyCode.X then
            local bv = Instance.new("BodyVelocity", airpad)
            bv.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
            bv.Velocity = Vector3.new(0,0,-6)
            wait(2)
            bv:Destroy()
        end
    end)
end

1 answer

Log in to vote
0
Answered by 1 year ago

It's isn't firing because you haven't defined the input ! Use InputBegan to make it works!

uis.InputBegan:Connect(function(input,gpe)
-- your script
end)
0
exactly what i did....... HKG_7551 -2 — 1y
Ad

Answer this question