-- SOLVED -- I had made a stupid mistake with "Pack1 = script.Parent" because the numbered TextButtons are actually script.Parent.Pack1!
Hi guys. I have this script that changes a decal depending on if a player has completed a level. All of the children of Pack1 are numbered 1 through to 12. This script has broken as I have commented down below.
Help much appreciated!
while true do
wait(2)
LevelsCompleted = game.Players.LocalPlayer.LevelsCompleted
Pack1 = script.Parent:GetChildren()
for i,child in pairs(Pack1) do
Level = tonumber(child.Name)
if Level <= LevelsCompleted.Value then -- this line errors. It says "cannot compare string with a number" or something similar.
child.ImageLabel.Image = "http://www.roblox.com/asset?id=173263900"
elseif (Level + 1) == LevelsCompleted.Value then
child.ImageLabel.Image = "http://www.roblox.com/asset?id=173701607"
else
child.ImageLabel.Image = "http://www.roblox.com/asset?id=173701600"
end
end
end

1 comment
On retesting the error has changed to "attempting to compare nil with a number" (Line 8). Not sure whats going on :p