#how to make part go to cursor
38 messages · Page 1 of 1 (latest)
Get the mouse
local player = workspace:GetService("Players").LocalPlayer
local mouse = player:GetMouse()
--then we get the hit position
local mousePos = mouse.Hit.p
Then use an object like a part set the position on it towards your mouse's cursor.
Loop it
After that use mouse.Target
To filter, just read the documentation about mouse too.
Np, you may close this post now if you'd like
were do i put the script
becuase i cant put it in a normal script
Local script
ok
will the block be the same for evreyone or will it only move for you
local player = game.Players.LocalPlayer
Part = game.Workspace:WaitForChild("Op")
local mouse = player:GetMouse()
local USI = game:GetService("UserInputService")
local been_Clicked = false
--then we get the hit position
local mousePosY = mouse.Hit.Y
local mousePosX = mouse.Hit.X
local function onIntputBegan(input, _gameProcessed)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
been_Clicked = true
local mousePosX = mouse.Hit.X
local mousePosY = mouse.Hit.Y
print("cliked")
Part.Position = Vector3(mousePosX, mousePosY, -18)
end
end
if been_Clicked then
print("true")
end
USI.InputBegan:Connect(onIntputBegan)
im t4rying to get it so the scroll wheel will cheange the z levle but i dont know how to put all X, Y in the pos with out it being an erorr
But why do you need a Input for it tho
becuase later im have it so you have to click on the part
im just going step by step
Ah
Yeah use a click detector
i tried but i get relly stuck on server comands
But you need to think outside of the box with that one
and modul scripts
You don't need module scripts for this one
oh
Part.Position.X = mousePosX
Part.Position.Y = mousePosY
Part.Position.Z = -18
output is saying x canot be assinged to?
Is MousePosX only the X?
yes
it only has opne vlaue in
local mousePosY = mouse.Hit.Y
local mousePosX = mouse.Hit.X
local function onIntputBegan(input, _gameProcessed)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
been_Clicked = true
local mousePosX = mouse.Hit.X
local mousePosY = mouse.Hit.Y
print("cliked")
Part.Position.X = mousePosX
Part.Position.Y = mousePosY
Part.Position.Z = -18
end
end
Mouse.Hit.Position retrieves a Vector/CFrame on the 3D world space
So you could've just gotten position of the part and then assign it on the mouse
how would i get it to ignor the z value