I followed a youtube tutorial, and I know the very basics of scripting but I'm gradually learning. When attempting to run the last part of the script, I get the error "ServerScriptService.OverheadHandler:17:attempt to index nil with 'destroy'" Can anyone help?
local serverStorage = game:GetService("ServerStorage") game.Players.PlayerAdded:Connect(function(plr) plr.CharacterAdded:Connect(function(char) local level = plr:WaitForChild("leaderstats").Rank.Level local levelVal = level.Value local rankTag = serverStorage:FindFirstChild(levelVal):Clone() rankTag.Parent = char.Head plr.leaderstats.Rank.Level.Changed:Connect(function() local level = plr:WaitForChild("leaderstats").Rank.Level local levelVal = level.Value local rankTag = serverStorage:FindFirstChild(levelVal):Clone() rankTag.Parent = char.Head local lastRank = levelVal - 1 if lastRank > 0 then char.Head:FindFirstChild(lastRank):Destroy() end end) end) end)
You cant destroy GUI u can only make it unvisible
GUI = char.Head:FindFirstChild(lastRank) GUI.Visible = False