How would I make this?

If I have a sword, what would I do if I wanted it to follow the players mouse while still staying on an axis like this:

Summary:

How do I make a sword follow a players mouse’s x axis?

1 Like
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local mouse = player:GetMouse()
local sword = --SWORD

local function updateSwordPosition()
sword.Position = Vector3.new(mouse.Hit.Position.X, sword.Position.Y, sword.Position.Z)
end

I am lowkey kinda confused on what exactly your doing, like is it a GUI? Or a part? Or do you want raycasting or just the mouse hit position?

1 Like

So I want the sword to move side to side with the mouse but NOT up and down with the mouse. Also model.

Yeah so in that case, the script I provided you will work, assuming you dont need raycasting or anything fancy

Also it is in 1st personand the player can’t move their camera

yes that is fine then, try the script I provided you with

it doesnt do anything… i just tested it.

Then that is a problem on your side, not the scrips problem because I can assure you that the script works. Perhaps send me a picture of your explorer

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.