#how to make part go to cursor

38 messages · Page 1 of 1 (latest)

heady forge
#

how to make part go to cursor

severe quiver
#

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.

heady forge
#

wait

#

ok

#

thanls

severe quiver
#

Np, you may close this post now if you'd like

heady forge
#

becuase i cant put it in a normal script

severe quiver
#

Local script

heady forge
#

ok

heady forge
heady forge
# severe quiver Local script
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

severe quiver
#

Why are you using UIS

#

The mouse has its own Events

heady forge
#

becuase ima use moues down later on

#

i dont know if click detector does that

severe quiver
#

But why do you need a Input for it tho

heady forge
#

becuase later im have it so you have to click on the part

#

im just going step by step

severe quiver
#

Yeah use a click detector

heady forge
#

i tried but i get relly stuck on server comands

severe quiver
#

But you need to think outside of the box with that one

heady forge
#

and modul scripts

severe quiver
heady forge
#
        Part.Position.X = mousePosX
        Part.Position.Y = mousePosY
        Part.Position.Z = -18

output is saying x canot be assinged to?

severe quiver
#

Is MousePosX only the X?

heady forge
#

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
severe quiver
#

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

heady forge
#

how would i get it to ignor the z value