#How do I get the direction the player is walking towards and rotate the parts?

1 messages · Page 1 of 1 (latest)

dark hazel
#

VFXModule: ```function VFXModule.RunningAir(Time,CentralPos,Direction,Amount)
for i = 1,Amount,1 do
local Sphere = RP.Assets.Sphere:Clone()
Sphere.Parent = DebrisFolder

    local Extend = CFrame.new(Vector3.new(math.random(-300,300)/100,math.random(-300,300)/100,math.random(0,675)/100))
    Sphere.CFrame = CentralPos * Extend

    Sphere.Size = Vector3.new(0.2,math.random(3,7),0.2)
    Sphere.CanCollide = false
    Sphere.Anchored = true
    Sphere.CastShadow = false
    Sphere.CanTouch = false
    Sphere.CanQuery = false

    local ColorNumber = math.random(1,3)

    if ColorNumber == 1 then
        Sphere.Color = Color3.new(0, 0, 0)
    else
        Sphere.Color = Color3.new(1, 1, 1)
    end

    local SphereInfo = TweenInfo.new(Time)

    local SphereTween = TS:Create(Sphere,SphereInfo,{Transparency = 1,Size = Vector3.new(0,0,0),CFrame = Sphere.CFrame * Direction})
    SphereTween:Play()

    game.Debris:AddItem(SphereTween,Time)
    game.Debris:AddItem(Sphere,Time)
end

end```

#

local script: ```local TCharacter = ThisGuy
if TCharacter == nil then
return
end
local THRP = TCharacter:FindFirstChild("HumanoidRootPart")

        if THRP == nil then
            return
        end
        
        local ThatHumanoid = TCharacter:FindFirstChildOfClass("Humanoid")
        if Humanoid == nil then
            return
        end
        
        local Tdirection = math.round(ThatHumanoid.MoveDirection:Dot(THRP.CFrame.LookVector))
        local Tdirection2 = math.round(ThatHumanoid.MoveDirection:Dot(THRP.CFrame.RightVector))

        local LookTo = CFrame.new(THRP.CFrame.LookVector) * CFrame.new(THRP.CFrame.RightVector)

        local Time = 0.3
        local CentralPos = THRP.CFrame * CFrame.Angles(math.rad(90),0,0) * CFrame.new(Vector3.new(0,0,-2.5)) * LookTo.Rotation
        local Direction = CFrame.new(Vector3.new(0,-2,0))
        local Amount = math.random(3,5)

        VFXModule.RunningAir(Time,CentralPos,Direction,Amount)```
raw robin
#

I think you might have todo this with UserInputService

dark hazel
#

ok

#

Isn't there another way?

tidal night
dark hazel
#

but not their actual look direction

tidal night
#

then, you can use the player's humanoid root part to get the look direction

dark hazel
#

Yes but what if the player has shiftlock and moves left or right?

#

How could I accomplish it?

tidal night
#

for that specific case, you could use userinputservice

dark hazel
#

ok

#

thanks