Hello I’m making a system for my game where you click on a tool to see the gui but their is an issue with this and to my believe their is no output in studio
my code:
script.Parent.Equipped:Connect(function()
if not game:GetService("Players").LocalPlayer.PlayerGui:FindFirstChild("BookGUI") then
BookGUI = script.Parent.BookGUI:Clone()
BookGUI.Parent = game:GetService("Players").LocalPlayer.PlayerGui
end
end)
script.Parent.Unequipped:Connect(function()
BookGUI:Destroy()
end)```
local Players = game:GetService("Players")
local Player = Players.LocalPlayer
script.Parent.Equipped:Connect(function()
if not Player:WaitForChild("PlayerGui"):FindFirstChild("BookGUI") then
local BookGUI = script.Parent:WaitForChild("BookGU"):Clone()
BookGUI.Parent = Player:WaitForChild("PlayerGui")
end
end)
script.Parent.Unequipped:Connect(function()
if Player:WaitForChild("PlayerGui"):FindFirstChild("BookGUI") then
Player:WaitForChild("PlayerGui"):FindFirstChild("BookGUI"):Destroy()
end
end)
local Players = game:GetService("Players")
local Player = Players.LocalPlayer
script.Parent.Equipped:Connect(function()
if not Player:WaitForChild("PlayerGui"):FindFirstChild("BookGUI") then
print("test")
local BookGUI = script.Parent:WaitForChild("BookGUI"):Clone()
BookGUI.Parent = Player:WaitForChild("PlayerGui")
end
end)
script.Parent.Unequipped:Connect(function()
if Player:WaitForChild("PlayerGui"):FindFirstChild("BookGUI") then
print("test2")
Player:WaitForChild("PlayerGui"):FindFirstChild("BookGUI"):Destroy()
end
end)
1: Is this a server script or a local script?
2: Why are you using if not game:GetService("Players").LocalPlayer.PlayerGui:FindFirstChild("BookGUI") then. Why is there a not in there?
local BookGUIClone = BookGUI:Clone()
BookGUIClone.Parent = Player:WaitForChild("PlayerGui")
script.Parent.Unequipped:Connect(function()
BookGUI:Destroy()
end)
--Didnt work
Output:
Workspace.EruptingStudiosGD.Book.LocalScript:3: attempt to index nil with 'WaitForChild'