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

Gui visible on torso click?

Asked by 10 years ago

How would I make a gui frame visible when a player clicks another players torso? Should I use the click detector way or what, I am pretty clueless on this and I would like to know how.

mouse.?:connect(function() --What should I replace ? with?

I have the function and I know how to click the players torso, but should I do just MouseButton1Down or something?

Attempt

local plr = game.Players.LocalPlayer;
local mouse = plr:GetMouse();
local Frame2 = script.Parent.Content

mouse.MouseButton1Down:connect(function()
 if game.Players:GetPlayerFromCharacter(mouse.Target.Parent) then 
Frame2.Visible = true; 
end
end)

1 answer

Log in to vote
2
Answered by 10 years ago

Your attempt was almost correct; the event is "Button1Down" for the PlayerMouse object. You also need to check if the mouse has a target, otherwise the script will error.

local plr = game.Players.LocalPlayer;
local mouse = plr:GetMouse();
local Frame2 = script.Parent.Content

mouse.Button1Down:connect(function()
    if mouse.Target and mouse.Target.Parent and game.Players:GetPlayerFromCharacter(mouse.Target.Parent) then 
        Frame2.Visible = true; 
    end
end)

0
This helped a lot, thanks! IntellectualBeing 430 — 10y
Ad

Answer this question