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

ROBLOX not registering clicking other player?

Asked by 4 years ago

I am trying to make Roblox show a GUI when you click another player and it does not print my print statement

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

Mouse.Button1Down:Connect(function()
    if Mouse.Target.Parent:FindFirstChild("Humanoid") then
        local clickedPlayer = game.Players:GetPlayerFromCharacter(Mouse.Target.Parent)
        print(Mouse.Target.Parent.Name)
    end 
end)
0
make sure your script is enabled (it happens easily that you deactivate scripts to check something and then forget to turn them back on) Gameplayer365247v2 1055 — 4y
0
script.Disabled is false silentkiller914 5 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

Works perfectly fine for me proof

But i recommend adding this (it prevents a error when you click at something that is nil / e.g the sky):

if Mouse.Target then

end

How it would look in the script:

Mouse.Button1Down:Connect(function()
    if Mouse.Target then
        if Mouse.Target.Parent:FindFirstChild("Humanoid") then
            local clickedPlayer = game.Players:GetPlayerFromCharacter(Mouse.Target.Parent)
            print(Mouse.Target.Parent.Name)
        end 
    end
end)
0
I now get this error: Workspace.Player2.Ragdoll:145: attempt to index local 'Humanoid' (a nil value) silentkiller914 5 — 4y
0
is this in a local script or server? NubScripters 126 — 4y
0
A local script silentkiller914 5 — 4y
0
ok on line "145" what is its code? is it "if Mouse.Target.Parent:FindFirstChild("Humanoid") then" ? "local clickedPlayer = game.Players:GetPlayerFromCharacter(Mouse.Target.Parent)" ? "print(Mouse.Target.Parent.Name)" ? etc NubScripters 126 — 4y
View all comments (3 more)
0
yea silentkiller914 5 — 4y
0
i don't know if these errors relate: silentkiller914 5 — 4y
0
Error checking in group: Player:GetRankInGroup failed because HTTP 0 (HTTP 400) Error checking in group: Player:IsInGroup failed because HTTP 0 (HTTP 400) Error checking in group: Player:GetRankInGroup failed because HTTP 0 (HTTP 400) Error checking in group: Player:IsInGroup failed because HTTP 0 (HTTP 400) silentkiller914 5 — 4y
Ad

Answer this question