Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why Doesn't the Z axis exist for the mouse, and is there way to get the Z axis?

Asked by 6 years ago
Edited 6 years ago

I'm making a while loop that will move the part to the mouse always, so I can create a building system.

--Variables
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local Part = game.Workspace.Farm:Clone()
Part.Parent = game.Workspace
--Move Part to Mouse Position Always
while true do
        local x = mouse.X
        local y = mouse.Y
        Part.Position = Vector3.new(x,y)

--Places Part at Mouse Position.
    mouse.Button1Down:connect(function(hit)
        local X = mouse.hit.X
        local Y = mouse.hit.Y
        local Z = mouse.hit.Z
        local Partt = Part:Clone()
        Partt.Parent = game.Workspace
        Partt.Anchored = true
        Partt.Position = Vector3.new(X,Y,Z)
        wait(5)
        Partt:Destroy()
    end)
    wait()
end

0
Mind showing code? c: It'll help us to further answer your question within the best of our abilities! :D TheeDeathCaster 2368 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

Well, the simple answer is no. Since Z would only exist on a 3D space. Unfortunately for mouse it exists on a two value plane. AKA X and Y which would both represent the position of the mouse on a 2D screen.

Ad

Answer this question