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

How would I make this model follow the mouse?

RunS.RenderStepped:connect(function()
	Gun:SetPrimaryPartCFrame(C["HumanoidRootPart"].CFrame*CFrame.new(0,1,2.5))
end)

So currently I made it so the model's Primary Part would follow the characters humanoid root-part by using run service and rendering it, but how would I make it so that it also follow's the player's mouse? Is this even possible? Thank you very much if you answered.

1 answer

✓ Accepted answer
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local rs = game:GetService("RunService").RenderStepped

local cf = CFrame.new

rs:connect(function()
	Gun:SetPrimaryPartCFrame(cf(mouse.Hit.p))
end)

Is this what you mean? mouse.Hit.p is a Vector3 value of the mouse's current position. This should work.

1 comment

0

Thanks for the help, currently what I'm trying to do isn't possible, but I'll accept your answer thank you.

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