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

How do i get the player using the mouse?

Asked by 4 years ago

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)
0
GetPlayerFromCharacter() on the parent of the BasePart that the mouse is pointing to DeceptiveCaster 3761 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

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)
0
Sure enough when i looked through, in the end I managed to fix it. Thanks for your help! Fl3eandFlo3e 18 — 4y
Ad

Answer this question