I have tried to make my part follow my mouse cursor in first person.
but my script does not seem to work.
Here it is:
local part = script.Parent
local function onMouseMove(x, y)
part.CFrame = CFrame.new(game.Workspace.CurrentCamera.WorldToViewPoint(Vector3.new(x, y, 0)))
end
game:GetService("UserInputService").InputChanged:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseMovement then
onMouseMove(input.Position.X, input.Position.Y)
end
end)
My goal for this script was to make a building system, and I got an idea for it, but I couldn’t script it.
You can only detect the input of a player within a local script, so you can detect input from a local script and sens the data with a remote event. If you don’t know how remote events work, i can explain them to you.
local mouse = game.Players.LocalPlayer:GetMouse()
local movepart -- Fill in this variable
mouse.TargetFilter = movepart
mouse.Move:Connect(function()
if mouse.Hit then
movepart.Position = mouse.Hit.Position
movepart.Parent = workspace -- Change to something else if you want
else
movepart.Parent = nil
end
end)
Do you even have a mouse in 1st person or a pointer icon set to the very middle of the screen …
Why wouldn’t screen width/2, screen height/2 be the point you’re looking for while in 1st person view?
can you please make it so it can go far for a sertain distance and go closer to the player with mouse scroll wheel and when it reachs the distance that has been selected with the mouse scroll wheel go up and down? and can i make it somehow make other players see the part move?
You probably don’t want to be able to see other people’s part move. What if somebody put it in your face the whole time? It should appear on their head, on their back, or in their hands while they’re placing it. Or even, it just wouldn’t show anywhere until they place it back down.
Oh Ok. Just a quick question how do i make it so the part has a specific radius and with the scroll of the mouse or on mobile i make it with buttons and make the part levitating up and down as the mouse goes up or down and rotation