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

How do you make player go right no matter what axis they are in?

Asked by 6 years ago

Hello, I have already asked this question before but worded it wrong. I would like to ask this question again. I made a script where it basically dashes the player to the Right Direction( like right and left ) . It only works in a single axis the rest other axises it just goes backwards or some other direction. I want this so no matter what axis the player is in they will always go to the right. here is my script:


local uis = game:GetService("UserInputService") local plr = game.Players.LocalPlayer local hum = plr.Character.Humanoid local cac = plr.Character uis.InputBegan:connect(function(i) if i.KeyCode == Enum.KeyCode.F then hum:ChangeState(Enum.HumanoidStateType.Jumping) cac.HumanoidRootPart.Velocity = game.Players.LocalPlayer.Character.Torso.CFrame.rightVector*50 end end)

thanks, activatesenju

0
Hmm. `cac`'s the player's character, but was defined after `hum`, and line 13 completely disregards the `cac` variable... TheeDeathCaster 2368 — 6y
0
I like to use HumanoidRootPart instead of torso, but that should always move the player to the right, not sure what the problem is Earthkingiv 51 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

uh i added the bodyvelocity instance and set the velocity thats all i did anyway

local uis = game:GetService("UserInputService")

local plr = game.Players.LocalPlayer
local hum = plr.Character.Humanoid
local cac = plr.Character

uis.InputBegan:connect(function(i)

    if i.KeyCode == Enum.KeyCode.F then

        hum:ChangeState(Enum.HumanoidStateType.Jumping)
        local ii = Instance.new("BodyVelocity", cac.HumanoidRootPart)
        ii.Name = "Velocity"
        ii.Velocity = game.Players.LocalPlayer.Character.LowerTorso.CFrame.rightVector*50
        wait(0.6)
        ii:Destroy()
    end

end)

managed to get it working put in starterpack if u dont know

0
thanks it works! I tried this before but it glitched for me, this time it worked. activatesenju 2 — 6y
Ad

Answer this question