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)

2 comments
I did that, it doesn't do it either, the issue seems to be that the GUI is parented to the player, and not their head.
Wait, nevermind, I figured out how to make your code work. Thanks!