I am trying to make a Spawner with a SurfaceGui in a certain way. I want to check if there's a certain model in the ServerStorage. An if not, I want to show a Frame for 8 seconds and return to start the start. But I'm not sure how to incorporate it into my code.
local c2 = game.ServerStorage.c2 script.Parent.MouseButton1Down:connect(function() game.ServerStorage.c2.Parent = workspace end)
local c2 = game:GetService("ServerStorage"):FindFirstChild("c2") script.Parent.MouseButton1Down:connect(function() if c2 then --not sure what your intended use is, but you may want to do c2:Clone().Parent = workspace instead c2.Parent = workspace else --show the frame, wait 8 seconds, hide the frame end end)
To have the code check for a certain item in any place, you must use FindFirstChild(""). You also don't need to direct to c2 again since you already defined the item earlier and you should define workspace beforehand.
local c2 = game.ServerStorage:FindFirstChild("c2") --FindFirstChild checks to see if an item exists local workspace = game.workspace --workspace isn't predefined local frame = game.StarterGuiname.Framename --define the frame here script.Parent.MouseButton1Down:connect(function() if c2 then c2.Parent = workspace --You already set the directory for c2 so you just need to call upon what you named the variable. else frame.Visible = true wait(8) frame.Visible = false end)