Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

2 comments

0

Hmm. cac's the player's character, but was defined after hum, and line 13 completely disregards the cac variable...

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

1 answer

✓ Accepted answer

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

1 comment

0

thanks it works! I tried this before but it glitched for me, this time it worked.

This discussion is preserved as it was. New answers, comments, and votes are closed.