I made a script using Topbarplus and it works but when I die, it breaks and says Infinite Yield Possible on WaitForChild(“Frame”) or Can only tween objects in Workspace. I tried adding a wait() and nothing works. I also know where the error is coming from, not sure how to fix it. Please help.
Output
14:57:26.731 Infinite yield possible on 'Inventory:WaitForChild("Frame")' - Studio
14:57:26.732 Stack Begin - Studio
wait(3)
local rs = game:GetService("ReplicatedStorage")
local icon = require(rs.Icon)
local iconcontrol = require(rs.Icon.IconController)
local tokens = icon.new()
local role = icon.new()
local inventory = icon.new()
local inventoryGui = game.Players.LocalPlayer.PlayerGui["Inventory"]
local open = inventoryGui.Open
local frame = inventoryGui.Frame
inventory:setLabel("Inventory")
inventory:bindEvent("selected",function(icon)
print("selected")
if open.Value == false then
inventoryGui:WaitForChild("Frame"):TweenPosition(UDim2.new(0.15, 0,0.127, 0),"Out","Quint",1,true)
open.Value = true
end
end)
inventory:bindEvent("deselected",function(icon)
print("deselected")
if open.Value == true then
inventoryGui:WaitForChild("Frame"):TweenPosition(UDim2.new(0.15, 0,-0.127,-420),"Out","Quint",1,true)
open.Value = false
end
end)
while true do
wait(1)
tokens:setImage("rbxassetid://10968264966")
role:setLabel("Role: "..game.Players.LocalPlayer:WaitForChild("leaderstats").Role.Value)
tokens:setLabel("Tokens: "..game.Players.LocalPlayer:WaitForChild("leaderstats").Tokens.Value)
end
task.wait(3)
local player = game.Players.LocalPlayer
local playerGui = player:WaitForChild("PlayerGui")
local rs = game:GetService("ReplicatedStorage")
local icon = require(rs.Icon)
local iconcontrol = require(rs.Icon.IconController)
local tokens = icon.new()
:lock()
:setImage("rbxassetid://10968264966")
local role = icon.new()
:lock()
local inventory = icon.new()
:setLabel("Inventory")
:bindEvent("selected", function(icon)
print("selected")
local inventoryGui = playerGui:WaitForChild("Inventory")
if inventoryGui.Open.Value == false then
inventoryGui:WaitForChild("Frame"):TweenPosition(UDim2.new(0.15, 0, 0.127, 0), "Out", "Quint", 1, true)
inventoryGui.Open.Value = true
end
end)
:bindEvent("deselected", function(icon)
print("deselected")
local inventoryGui = playerGui:WaitForChild("Inventory")
if inventoryGui.Open.Value == true then
inventoryGui:WaitForChild("Frame"):TweenPosition(UDim2.new(0.15, 0, -0.127, -420), "Out", "Quint", 1, true)
inventoryGui.Open.Value = false
end
end)
local leaderstats = player:WaitForChild("leaderstats", 20)
local roleValue = leaderstats:WaitForChild("Role", 7.5)
local tokensValue = leaderstats:WaitForChild("Tokens", 7.5)
while task.wait(1) do
role:setLabel("Role: ".. roleValue.Value)
tokens:setLabel("Tokens: ".. tokensValue.Value)
end