How would I make this point where the mouse is?


I am trying to make this point where the mouse would point, but I don’t know how is the issue, I actually have no idea how I would make this.
Suggestions would be appreciated.
I forgot a part of the code of the CFrame where it makes a part of the primary part of a model rotate in a certain direction, so I just need suggestions or major ideas.

You’re probably looking for :GetMouse

https://developer.roblox.com/en-us/api-reference/class/Mouse

I know GetMouse, but I just don’t know how I would make the exact model rotate to where the mouse is, ex: I want an Arrow in the workspace to point to where the mouse is.

Edit: Rotate would only set it, not continously, and I don’t know how I would convert the position into the rotation.

You could bind this to renderstepped or whenever the mouse moves:

primaryPart.CFrame = CFrame.new(primaryPart.Position, mouse.Hit.Position)

PrimaryPart is the PrimaryPart of the model. It should be anchored. Every other part in the model should be unanchored and welded to the PrimaryPart.

I mean I am using a local script which is placed into the model and it quite isn’t moving.
EDIT:

local primaryPart = script.Parent.PrimaryPart
mouse = game.Players.LocalPlayer:GetMouse()
local berb = game:GetService('RunService')
berb.RenderStepped:connect(function()
primaryPart.CFrame = CFrame.new(primaryPart.Position, mouse.Hit.Position)
end)

Also tried local to server.

Make sure that nothing else in the model is anchored.

It is, and the model just, dissapears.
Script:

local primaryPart = script.Parent.PrimaryPart
game.ReplicatedStorage.catcj.OnServerEvent:Connect(function(mouse)
primaryPart.CFrame = CFrame.new(Vector3.new(primaryPart.Position, mouse))
end)

Local script:

mouse = game.Players.LocalPlayer:GetMouse()
local berb = game:GetService('RunService')
berb.RenderStepped:connect(function()
game.ReplicatedStorage.catcj:FireServer(mouse.Hit.Position)
end)

If you give me a place file I might be able to look at it and see what’s wrong. I have it working with a quick model that I whipped up:

1 Like