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

How do i get the player using the mouse?

You can get the player using local player and player functions but how do you get it using the mouse? I've tried using Mouse.Target which gets non-living objects but it doesn't get the player. How do i get the player using the mouse?

local mouse = player:GetMouse()
  local click = false
	local function onclick()
		if not click then
			click = true
	print(mouse.Target)
	wait(0.5)
	click = false
	end
end
mouse.Button1Down:Connect(onclick)

1 comment

0

GetPlayerFromCharacter() on the parent of the BasePart that the mouse is pointing to

1 answer

✓ Accepted answer

This is not a request site!

But luckily it is easy to do with the proper variables and functions.

PUT THIS IN STARTERGUI!.

I worked through your script and i found the solution and you didn't define a variable for player. Another error you had is that you didn't know who to correctly define a OnClick function with a player mouse. Also if you ask me but what i can tell by the script this is poor understanding of code especially when its client sided.

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

local click = false

local function OnClick()
	if click == false then
		click = true
		print(Mouse.Target)
		wait(1)
		click = false
	end
end

Mouse.Button1Down:Connect(OnClick)

1 comment

0

Sure enough when i looked through, in the end I managed to fix it. Thanks for your help!

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