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

I'm trying To Get The Mouse.Target's Position The Whole Day, Can Somebody Help?

script.Parent.OnServerEvent:Connect(function(Block, Target, plr)
	local TargetPostion = Target.Position
	local RSBlock = game.ReplicatedStorage:FindFirstChild(Block)
	
	if plr.Blocks[Block].Value < 1 then
		print("You Don't Have That Block")
	else
		local RBlock = RSBlock:Clone()
		
		RBlock.Parent = game.Workspace
		if Target.Name == "BuildingFrame" then
			local ActualPosition = Target:GetPosition()
			
			RBlock.Position = Vector3.new(ActualPosition)
		end
	end
end)

So I Tried To Do Mouse.Target:GetPosition() Or Mouse.Target.Position, But None Of it Works! Please Help

3 comments

0

please throw in your script. because we can't help you if you don't put your script. Thanks. In the meat

0

aight

0

done

1 answer

First and foremost, GetPosition isn't a method of the mouse object


Mouse Object


In roblox, you can use the GetMouse() function on the client to get the mouse of the local player.

Like such:

local plr = game.Players.LocalPlayer
local Mouse = plr:GetMouse()

Mouse 3D position


If you want to get the 3D position of the mouse at any time, you would use the Hit property of the mouse, which is a CFrame value, then you can get the Position matrix of said cframe value.

For Example:

local plr = game.Players.LocalPlayer
local Mouse = plr:GetMouse()
print(Mouse.Hit.Position)--Vector3 position of the mouse

Position of the Mouse Target


On the other hand, if you want to get the position of the Mouse Target, which is an object or nil, instead of a cframe, you would do:

local plr = game.Players.LocalPlayer
local Mouse = plr:GetMouse()
print(Mouse.Target.Position)--Vector3 position of the mouse Target
print(Mouse.Target.CFrame.Position)--also works

Important Note: you can not get the mouse object on the server, as it doesn't replicate to the server, you can send over properties like target and Hit via remotes

2 comments

0

i'll try

0

i'll try

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