Hello, I’m having an issue with a Gui, when I try to parent it the first time to PlayerGui it works fine without any issues, but when I parent it to ReplicatedStorage and then back to PlayerGui it no longer works. Does anyone know why this might happen?
Here are the scripts:
LocalScript in the Tool I’m using to parent the Gui.
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Components = ReplicatedStorage:WaitForChild("Components")
local Equipment = Components:WaitForChild("Equipment")
local Scientist = Equipment:WaitForChild("Scientist")
local Gui = Scientist:WaitForChild("Gui")
local StarterGui = game:GetService("StarterGui")
local Tool = script.Parent
local Clipboard = Gui:WaitForChild("ClipboardGui")
local Player = Players.LocalPlayer
local PlayerGui = Player.PlayerGui
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
Tool.Equipped:Connect(function()
Clipboard.Enabled = true
Clipboard.Parent = Player.PlayerGui
end)
Tool.Unequipped:Connect(function()
Clipboard.Enabled = false
Clipboard.Parent = Gui
end)
Humanoid.Died:Connect(function()
Clipboard.Enabled = false
Clipboard.Parent = Gui
end)
LocalScript inside the Gui that doesn’t work after re-parenting to PlayerGui
local Main = script.Parent
local CurrentPage = Main:WaitForChild("CurrentPage")
local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
local CURRENT_PAGE = 1
local MAX_PAGES = 10
CurrentPage.Text = string.format("Page %s", CURRENT_PAGE)
for i = CURRENT_PAGE, MAX_PAGES, 1 do
if #Main.Pages:GetChildren() >= MAX_PAGES then return end
local template = script.Template:Clone()
template.Name = tostring(i)
if i == CURRENT_PAGE then
template.Content.Visible = true
template.Title.Visible = true
end
template.Parent = Main.Pages
end
local function HideAllPages()
for _, page in pairs(Main.Pages:GetDescendants()) do
if page:IsA("TextBox") then
page.Visible = false
end
end
end
local function ShowPage()
local Page = Main.Pages[CURRENT_PAGE]
for _, page in pairs(Page:GetChildren()) do
if page:IsA("TextBox") then
page.Visible = true
end
end
end
Main.NextPage.MouseButton1Down:Connect(function()
CURRENT_PAGE += 1
Main.CurrentPage.Text = string.format("Page %s", CURRENT_PAGE)
HideAllPages()
ShowPage()
if CURRENT_PAGE >= MAX_PAGES then
Main.NextPage.Visible = false
Main.PageBack.Visible = true
return
end
if CURRENT_PAGE > 1 then
Main.PageBack.Visible = true
end
end)
Main.PageBack.MouseButton1Down:Connect(function()
CURRENT_PAGE -= 1
Main.CurrentPage.Text = string.format("Page %s", CURRENT_PAGE)
HideAllPages()
ShowPage()
if CURRENT_PAGE <= 1 then
Main.PageBack.Visible = false
Main.NextPage.Visible = true
return
end
if CURRENT_PAGE > 1 and CURRENT_PAGE <= MAX_PAGES then
Main.NextPage.Visible = true
end
end)
If anyone knows why this is happening please tell me, I’ve been trying to figure it out for the past few hours with no success. And yes, I have tried using a script to parent it aswell and that didn’t work either.