Hey, guys. I'm trying to make a gui appear on the screen when you click on a part. I've already achieved doing this using a Click Detector inside the part, but I was wondering how you would accomplish this using Suface Gui. This is what I tried doing so far:
script.Parent.MouseButton1Click:connect(function(Player) local part = script.Parent.Parent.Parent local gui = part:FindFirstChild("ScreenGui") part.BrickColor = BrickColor.new("Really red") if gui then local newgui = gui:Clone() newgui.Parent = Player.PlayerGui end wait(1) part.BrickColor = BrickColor.new("Dark stone grey") end)
As you can see, the color of the brick changes red as expected (line 4), but the gui doesn't clone (line 7). I'm having trouble figuring out how I would locate the player that clicked the part, and I would gladly appreciate anyone how could help me solve this problem.
MouseButton1Click
does not return "Player". The best way to do this is to make this into a LocalScript
defining player as LocalPlayer
, you will then have to set the Adornee
of the SurfaceGui
to the part in workspace
you would like it to appear on.