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

Can someone help me with printing mouse position if they mooved for example X+10, Y+10 ,Z+10?

Basically, my script is to print me in output when mouse position moved for X Y or Z but the problem is that this doesn't work. Can someone help me out, please?

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local camerapart = game.Workspace.CameraPart
local X = mouse.X
local Y = mouse.Y
local Z = mouse.Z
if mouse.Position(X+1,Y,Z) then
	print("Mouse moved X+10")
end
if mouse.Position(X-1,Y,Z) then
	print("Mouse moved X-10")
end
if mouse.Position(X,Y,Z+1) then
	print("Mouse moved Z+10")
end
if mouse.Position(X,Y,Z-1) then
	print("Mouse moved Z-10")
end
if mouse.Position(X,Y+1,Z) then
	print("Mouse moved Y+10")
end
if mouse.Position(X,Y-1,Z) then
	print("Mouse moved Y-10")
end

The problem is not that it gives me an error. Problem is that it doesn't print it.

2 comments

0

you're trying to call Position like a function and mouse doesn't have a property called "Position" at all. Can you better explain what you think that's supposed to mean?

0

Nevermind now. I used top-down camera and tryied to move it if my mouse moves to the corner of screen. I think thats too much so I made WASD to move camera.

1 answer

I'm not sure what you are trying to do here. If you're trying to find the mouse's position in world space, you can do this:

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()

mouse.Move:Connect(function()
	local position = mouse.Hit.p
	print(position)
end)

4 comments

0

It doesn't print me a position D:

0

Nevermind it prints position right now

0

But can you make it that it prints every time when X or Y or Z changes for 10. Something like if position(X+10, Y, Z) then print("Moved")

0

Save the last position where it printed 'Moved', and then keep on checking if any of the axes are moved by 10, if so, change the variable to the current position, and print moved.

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