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

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

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

1 comment

0

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

1 answer

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.

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