I wanted a gui to pop up whenever you clicked a block, but it didn’t work.
Here’s my code.
local clickdetector = script.Parent
local Table = script.Parent.Parent
local status = game.ReplicatedStorage.Status
local gui = game.StarterGui.ScreenGui
script.Parent.MouseClick:Connect(function()
gui.Enabled = true
end)
First of all, you’re changing the value of the Screengui inside of Startergui, which only changes the value inside of startergui. Instead, get the player that clicked the ClickDetector, like this:
script.Parent.MouseClick:Connect(function(player)
From here, go into the PlayerGui and set the ScreenGui enabled to true. Like this:
Also what’s this status for? And btw i assume you are using a LocalScript and not a regular Script. And the LocalScript Placed inside the PlayerScripts or StarterGui and not in workspace cause otherwise its not gonna work
ClickDetector has a player argument on the MouseClick function.
Example:
ClickDetector.MouseClick:Connect(function(plr)
plr.PlayerGui.GuiToOpen.Enabled = true
end)
Did you do some debuging? Is there any error in developer Console? Is your script a local script or regular script? If local script if its inside the workspace its not going to work it has to be inside StarterPlayerScripts or StarterGui in your case.
If I’m not mistaken, you want the UI to appear on the player’s screen when they click a block. (please correct me if I’m wrong)
What your code does is simply changing the property of the game’s version of the UI. It’s not actually in the player at that point. You need to index the specific UI in the player’s gui folder for it to enable the UI on the player.
Try putting this in a localscript under the click detector.
local plr = game.Players.LocalPlayer
local gui = plr.PlayerGui:FindFirstChild("ScreenGui")
script.Parent.MouseClick:Connect(function()
gui.Enabled = true
end)
I’m not sure if this is exactly what your setup will work with, but it’s worth a shot given the small amount of information we have.
If what notsfeelings said doesn’t work either which in theory it should just like what the rest of us said it would be a good thing if you could also provide us an image in the explorer of how things are and located so we can get a better understanding of the issue