I need help with the "ScreenGui" object in Roblox. I am trying to write code that will allow a gui to pop up when a player clicks on a block through the gui will not show. The script calling the function to make the gui pop up is under workspace and the script creating the gui is in the startergui folder.
This is the script that is calling the other one:
script.Parent.ClickDetector.MouseClick:connect(shared["ShowGui"]);
The script to be called is:
shared["ShowGui"] = function()
print("Hello World");
sg = Instance.new("ScreenGui", game.StarterGui);
fr = Instance.new("Frame", sg);
fr.Size = UDim2.new(0,200,0,60);
fr.Position = UDim2.new(0, 0, 0.5, -60);
fr.Visible = true;
fr.Active = true;
fr.BackgroundColor3 = Color3.new(1, 0, 0);
end
The function is being called as when I click the block, the console is outputting "Hello World", so I know that it is being called.
I also tested the code without it being a function and the gui shows up as it should.
So now I'm just trying to figure out why it won't create the gui when the script is being called as a function.
First i find the seperation of the scripts ilogical. Second if you put a gui in the StarterGui it will ONLY be seen after you respawn.
All gui objects in the StarterGui is relicated to players' PlayerGui once they respawn.
try to put this script in the brick instead:
I am currently not able to test run the code, so it might not work as i expect.