Hello!
I made a script so that if the GUI was in PlayerGui, the script would stop, and play after the GUI was gone.
But it doesn’t work for some reason >:(
What other ways are there? Or tell me why it’s not working for me
-- CHECK IF ALREADY HAVE GUI
local Check = Player.PlayerGui:FindFirstChild("NewItemHolder")
if Check then
repeat task.wait()
print(tick())
until not Player.PlayerGui:FindFirstChild("NewItemHolder")
end
-- CHECK IF ALREADY HAVE GUI
local SS = game:GetService("ServerStorage")
local _Itemmodule = {}
function _Itemmodule.Add(Player,ItemName,RareType,Action)
local Tools = SS:WaitForChild("Assets")
local _CurrentFolder = Tools:FindFirstChild(Action)
local _RareFolder =_CurrentFolder:FindFirstChild(RareType)
local _CurrentItem = _RareFolder:FindFirstChild(RareType.." "..ItemName)
if _CurrentItem then
_CurrentItem.Parent = Player.Backpack
end
end
function _Itemmodule.Message(Player,Item,RareType)
local Models = SS:WaitForChild("Assets"):WaitForChild("Models")
local _CurrentModel = Models:FindFirstChild(RareType.." "..Item)
local _CloneGui = script:WaitForChild("NewItemHolder"):Clone()
local _RemoteEvent = _CloneGui:WaitForChild("Showcase")
if _CurrentModel then
-- CHECK IF ALREADY HAVE GUI
local Check = Player.PlayerGui:FindFirstChild("NewItemHolder")
if Check then
repeat wait() print(tick()) until Player.PlayerGui:FindFirstChild("NewItemHolder") == nil
end
-- CHECK IF ALREADY HAVE GUI
-- code:
for i,v in ipairs(_CloneGui:GetDescendants()) do
if v:IsA("Script") or v:IsA("LocalScript") then
if v.Name ~= "Ignore" then
v.Enabled = true
end
end
end
task.wait()
_CloneGui.Parent = Player.PlayerGui
_CurrentModel.Parent = _CloneGui.Holder.ViewportFrame.WorldModel
_RemoteEvent:FireClient(Player,_CurrentModel.Name,RareType)
else
warn("Item not found")
end
end
return _Itemmodule