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

Gui visible on torso click?

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

✓ Accepted answer

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)

1 comment

0

This helped a lot, thanks!

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