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

Struggling to make a pop up gui form clicking a brick?

I want to make a guis enabled property to be changed to true when a part is clicked.

Heres the script I made which isn't working.

local Part = script.Parent

Part.ClickDetector.MouseClick:Connect(function()

game.StarterGui.ScreenGui.Enabled = true

end)

Note: This is all in a local script which is inside the part I want to click.

1 answer

✓ Accepted answer

A LocalScript cannot run in workspace, it is a global environment; LocalScripts are meant to run on the local machine, you're trying to handle this within a Server ground.

StarterGui is also a replication container, much like StarterGear, this is not the active location of the Instances you wish to reference—they're moved over to a folder named PlayerGui. To properly interact with the local interface, you must gain access to this container through the Player.

Although, ServerScript's cannot allocate any Player Objects as it is a Server Operation—the Server does not contain a "local Player"—we can still manipulate them if received. Fortunately enough, the .MouseClick signal return the Player Object initiating the ClickDetector.

--< ServerScript

local clickDetector = script.Parent:FindFirstChildOfClass("ClickDetector")

clickDetector.MouseClick:Connect(function(playerClicked)
	local playerGui = playerClicked:FindFirstChild("PlayerGui")
	if (playerGui) then
		playerGui.ScreenGui.Enabled = true
	end
end)

2 comments

0

Thanks

0

No problem!

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