Hello!
I am making a book tool where you equip it, there is a book you can read. When I die and try to open it again, the gui doesnt show up and “BookTemplate is not a valid member of ScreenGui “BookGUI”” pops up.
How can I fix this? I tried turning off “ResetOnSpawn” to false but if I die with the tool equipped, I will respawn with the book gui still on my screen, so that doesn’t work.
Here is my script:
local PlayerGui = game.Players.LocalPlayer:WaitForChild("PlayerGui")
local Book = PlayerGui:WaitForChild("BookGUI")
local function OnEquip()
Book.BookTemplate.Enabled = true
Book.FrontPage.Enabled = true
Book.Page1.Enabled = false
Book.Page2.Enabled = false
Book.Page3.Enabled = false
Book.Page4.Enabled = false
Book.Page5.Enabled = false
Book.Page6.Enabled = false
Book.Page7.Enabled = false
Book.Page8.Enabled = false
Book.Page9.Enabled = false
Book.Page10.Enabled = false
Book.Page11.Enabled = false
Book.Page12.Enabled = false
Book.Page13.Enabled = false
Book.Next.Active = true
Book.Next.Visible = true
end
local function OnUnequip()
Book.BookTemplate.Enabled = false
Book.FrontPage.Enabled = false
Book.Page1.Enabled = false
Book.Page2.Enabled = false
Book.Page3.Enabled = false
Book.Page4.Enabled = false
Book.Page5.Enabled = false
Book.Page6.Enabled = false
Book.Page7.Enabled = false
Book.Page8.Enabled = false
Book.Page9.Enabled = false
Book.Page10.Enabled = false
Book.Page11.Enabled = false
Book.Page12.Enabled = false
Book.Page13.Enabled = false
Book.Next.Active = false
Book.Next.Visible = false
Book.Back.Active = false
Book.Back.Visible = false
Book.Page.Value = 0
end
script.Parent.Equipped:Connect(function()
OnEquip()
end)
script.Parent.Unequipped:Connect(function()
OnUnequip()
end)
Thanks!
heisIlan
(Ilan)
February 13, 2022, 11:30pm
#2
Disable the “ResetOnSpawn” property on the PlayerGui.
(By the way, you should use a loop instead of setting everything to false and true on over 10 lines)
ShafiDev
(ShafiDev)
February 13, 2022, 11:34pm
#3
You should try enabling ResetOnSpawn property and just declare the
local PlayerGui = game.Players.LocalPlayer:WaitForChild(“PlayerGui”)
local Book = PlayerGui:WaitForChild(“BookGUI”)
inside ur OnEquip function and it should start working so its gonna look like this
local function OnEquip()
local PlayerGui = game.Players.LocalPlayer:WaitForChild("PlayerGui")
local Book = PlayerGui:WaitForChild("BookGUI")
Book.BookTemplate.Enabled = true
Book.FrontPage.Enabled = true
Book.Page1.Enabled = false
Book.Page2.Enabled = false
Book.Page3.Enabled = false
Book.Page4.Enabled = false
Book.Page5.Enabled = false
Book.Page6.Enabled = false
Book.Page7.Enabled = false
Book.Page8.Enabled = false
Book.Page9.Enabled = false
Book.Page10.Enabled = false
Book.Page11.Enabled = false
Book.Page12.Enabled = false
Book.Page13.Enabled = false
Book.Next.Active = true
Book.Next.Visible = true
end
local function OnUnequip()
local PlayerGui = game.Players.LocalPlayer:WaitForChild("PlayerGui")
local Book = PlayerGui:WaitForChild("BookGUI")
Book.BookTemplate.Enabled = false
Book.FrontPage.Enabled = false
Book.Page1.Enabled = false
Book.Page2.Enabled = false
Book.Page3.Enabled = false
Book.Page4.Enabled = false
Book.Page5.Enabled = false
Book.Page6.Enabled = false
Book.Page7.Enabled = false
Book.Page8.Enabled = false
Book.Page9.Enabled = false
Book.Page10.Enabled = false
Book.Page11.Enabled = false
Book.Page12.Enabled = false
Book.Page13.Enabled = false
Book.Next.Active = false
Book.Next.Visible = false
Book.Back.Active = false
Book.Back.Visible = false
Book.Page.Value = 0
end
script.Parent.Equipped:Connect(function()
OnEquip()
end)
script.Parent.Unequipped:Connect(function()
OnUnequip()
end)
This works, thank you very much!
1 Like
Forummer
(Forummer)
February 14, 2022, 11:01am
#5
“ResetOnSpawn” is enabled by default.