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

How do i enable a Gui from a script?

I have a regenerate script that would regenerate models after a certain time. I want to set it so it would enable a Gui from the script right after regenerating. I have tried multiple times but can't get it to enable. Please help, thanks. Here's what i have:

object = script.Parent 
if (object ~= nil) and (object ~= game.Workspace) then 
model = object 

local message = game.workspace.StarterGui.Regen
message.Enabled = false
backup = model:clone() -- Make the backup 
waitTime = 8 --Time to wait between regenerations 
wait(math.random(0, waitTime)) 
while true do 
wait(waitTime) -- Regen wait time 

model:remove() 

wait(4.5) -- Display regen message for this amount of time 

model = backup:clone() 
model.Parent = game.Workspace 
model:makeJoints()
message.Enabled = true
end 
end

1 answer

✓ Accepted answer

I am really not sure what you are trying to do, but.. read the green lines to understand what I did.

object = script.Parent 
if (object ~= nil) and (object ~= game.Workspace) then 
model = object 

local message = game.Players.[PUTTHENAMEOFTHEPLAYERHERE].PlayerGui.Regen -- Wait this does not work at all! because this is in the StarterGui!! You should make it likeplayergui
message.Visible = false -- look It should be message.Visible = false, because there is no property of a gui called "Enabled"
backup = model:clone() -- Make the backup 
waitTime = 8 --Time to wait between regenerations 
wait(math.random(0, waitTime))  -- Im not really sure what you are trying to do here but what are you trying to randomize here :l
while true do 
wait(waitTime) -- Regen wait time 

model:remove() 

message.Visible = true -- you shouldn't put this below if you want to display this for that amount of time
wait(4.5) -- Display regen message for this amount of time 

model = backup:clone() 
model.Parent = game.Workspace 
model:makeJoints()
end 
end

Here is just something I need to say.. It's not showing up because "Enabled" property is only for .ScreenGui not for Regen because regen might be actually a frame.. If you are gonna use enable use it in ScreenGui not in Frames, If you want it to show up your frame you should use "Visible" like :

message.Visible = true

that's all I guess??

Hope this helped, If this helped (which I really don't think so because I didn't test this script and said some random words) if this actually worked, hit accept answer :))

8 comments

0

Okay, so now i understand that i have to go to PlayerGui instead of StarterGui. But instead of making the script go to just one player, i want to make it go to every player in game. I tried game.Players.LocalPlayer.PlayerGui.Regen and it didn't work. Btw, when i put my player name in the space, (in studio it's Player1) it still didn't work.

0

Oh okay give me a sec, can you give me access to your game?

0

are you using local script?

0

Mayk simply do this

0

Do you still need access to my game? I'm still kinda confused with this. I'm not a very good scripter

0

By the way, "Regen" was a GuiMain but i changed it

0

Changed it into a ScreenGui

0

Also, the script is in workspace because what i'm trying to do is i'm trying to have it regenerate a model and as the model regenerates, i want that gui to show on screen for a certain amount of time.

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