So pretty much what this script is supposed to do it's supposed to look for a change to an int value when it detects that the int value is set to 150 or more it's supposed to clone the GUI and set it's parent to starter gui. I tested it and it's not cloning or even setting its parent to starter gui. Here is the code:
local Storage = game.Workspace:WaitForChild("Storage1") local Storage1 = game.Workspace.Storage1 local MaxValue = 150 local Gui = script.Parent.Main.SellGui if(Storage1.Value >= 150) then Gui:Clone() Gui.Parent = "StarterGui" while true do wait() end end
Found it. Dont clone the gui to StarterGui. Place it to the playergui from the player.
script:
local Storage = game.Workspace:WaitForChild("Storage1") local Storage1 = game.Workspace.Storage1 local MaxValue = 150 local Gui = script.Parent.Main.SellGui if(Storage1.Value >= 150) then Gui:Clone() Gui.Parent = game.Players.LocalPlayer:WaitForChild("PlayerGui") while true do wait() end end
if the script is actually a normal script, please comment on my answer.
A couple of things wrong with your code, first there is no event listener, meaning that this script will only run once and thats it, even if your Storage1 value changes to more than 150 nothing will happen as the script already ended long before that, you can use the .Changed
event so that whenever storage1 value changes, it will check if its more than 150
Secondly, setting the parent of the gui is not done by indicating Strings, you have to indicate the parent as an object. Ill show you what i mean in the code.
local Storage = game.Workspace:WaitForChild("Storage1") local Storage1 = game.Workspace.Storage1 -- you dont have to assign the variable twice, the first line already assigns the variable local MaxValue = 150 local Gui = script.Parent.Main.SellGui --add an event listener here if(Storage1.Value >= 150) then Gui:Clone()-- assign this Cloned gui to a variable Gui.Parent = "StarterGui"-- this wont work while true do wait() end end
Also i am not sure if you know this but you should put the gui into playerGuis instead if you want the player to see the gui immediately, Startergui only works when the player joins the game, or respawns
local Storage = game.Workspace:WaitForChild("Storage1") local MaxValue = 150 local Gui = script.Parent.Main.SellGui Storage.Changed:Connect(function() if(Storage1.Value >= 150) then local ClonedGUI = Gui:Clone() ClonedGUI.Parent = game.StarterGui--the player will only see the gui when he respawns while true do wait() end end end()