-- 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!
01 | while true do |
02 | wait( 2 ) |
03 | LevelsCompleted = game.Players.LocalPlayer.LevelsCompleted |
04 | Pack 1 = script.Parent:GetChildren() |
05 |
06 | for i,child in pairs (Pack 1 ) do |
07 | Level = tonumber (child.Name) |
08 | if Level < = LevelsCompleted.Value then -- this line errors. It says "cannot compare string with a number" or something similar. |
09 | child.ImageLabel.Image = "http://www.roblox.com/asset?id=173263900" |
10 | elseif (Level + 1 ) = = LevelsCompleted.Value then |
11 | child.ImageLabel.Image = "http://www.roblox.com/asset?id=173701607" |
12 | else |
13 | child.ImageLabel.Image = "http://www.roblox.com/asset?id=173701600" |
14 |
15 | end |
16 | end |
17 |
18 | end |
Check if the child's name is not a string...
01 | while true do |
02 | wait( 2 ) |
03 | LevelsCompleted = game.Players.LocalPlayer.LevelsCompleted |
04 | Pack 1 = script.Parent:GetChildren() |
05 |
06 | for i,child in pairs (Pack 1 ) do |
07 | if tonumber (child.Name) ~ = nil then --Checks if the name is not a string. |
08 | Level = tonumber (child.Name) |
09 | if Level < = LevelsCompleted.Value then -- this line errors. It says "cannot compare string with a number" or something similar. |
10 | child.ImageLabel.Image = "http://www.roblox.com/asset?id=173263900" |
11 | elseif (number + 1 ) = = LevelsCompleted.Value then |
12 | child.ImageLabel.Image = "http://www.roblox.com/asset?id=173701607" |
13 | else |
14 | child.ImageLabel.Image = "http://www.roblox.com/asset?id=173701600" |
15 |
16 | end |
17 | end |
18 | end |
19 |
20 | end |
Sorry if this doesn't work, if it doesn't then i'll try look for a solution.