Help with a script

local UserInputService = game:GetService("UserInputService")
local AttackVFX = game.Workspace.ATTACKVFX

local function attackfunction()
    UserInputService.InputBegan:Connect(function(input, gameProccesedEvent)
        if input.KeyCode == Enum.KeyCode.F then
            AttackVFX.CFrame =
            local instance = AttackVFX
            local Information =,Enum.EasingStyle.Linear,Enum.EasingDirection.In)
            game:GetService("TweenService"):Create(AttackVFX,Information,{CFrame = instance.CFrame + (instance.CFrame.LookVector * 5)}):Play()


How do I make the AttackVFX move forward where the player is facing? Right now it just moves in a set direction

1 Like

Try using the LookVector of the player’s humanoidroodpart

{CFrame = instance.CFrame + (game.Players.LocalPlayer.Character:FindFirstChild("HumanoidRootPart").CFrame.LookVector * 5)}

game:GetService("TweenService"):Create(AttackVFX,Information,{CFrame = instance.CFrame + (game.Players.LocalPlayer.Character:FindFirstChild("HumanoidRootPart").CFrame.LookVector * 5)}
so something like this?

1 Like

Ok, so I tried this and I don’t think it works. Instead of moving forward, it just stays still.

Here’s a video example

Replace this with

local char = game.Players.LocalPlayer.Character
AttackVFX.CFrame = CFrame.lookAt(char.RightHand.Position,char.RightHand.Position+char.HumanoidRootPart.LookVector)

LookVector is not a valid member of Part “Workspace.TheFreeScriptDev.HumanoidRootPart” - Client - LocalScript:9
21:09:16.768 Stack Begin - Studio

Oh wait, I forgot to index cframe, use this instead

local char = game.Players.LocalPlayer.Character
AttackVFX.CFrame = CFrame.lookAt(char.RightHand.Position,char.RightHand.Position+char.HumanoidRootPart.CFrame.LookVector)

Thank you, the rotation is working now. Although it’s now not moving forward- just staying idle now.

Sorry for the late reply

So your saying, this line is not working?

Your code should work as-is if you changed this line to:

            AttackVFX.CFrame = game.Players.LocalPlayer.Character.RightHand.CFrame

This is because you’re placing the AttackVFX to the arm’s position without any orientation, then making the AttackVFX move forward in the direction it’s pointing in, which is always the same direction because it’s not using the arm’s rotation.

The other option, if for some reason that was intentional, is to use the arm’s direction in the tween:

            game:GetService("TweenService"):Create(AttackVFX,Information,{CFrame = instance.CFrame + (game.Players.LocalPlayer.Character.RightHand.CFrame.LookVector * 5)}):Play()

However, the arm might have moved in that 0.5sec. If you do this, you should put the CFrame of the arm in a variable before the `wait(0.5) and use that to get the LookVector.

1 Like