Why are these lines either not running or running twice?
I am making a tycoon game that saves your data. I have saved and loaded the data but now when someone claims their tycoon, the code that looks through what the player owns doesn't work very well.
line 37 is either not running or is being overrited by line 62
01 | for i, v in pairs (player.PurchaseFolder:GetChildren()) do |
02 | for i, t in pairs (script.Parent.Parent.Buttons:GetChildren()) do |
03 | if v.Value = = t.Name then |
04 | for i, o in pairs (script.Parent.Parent.Buyable:GetChildren()) do |
05 | local str = string.split(t.Name, " " ) |
06 | local str 2 = string.split(o.Name, " " ) |
09 | if str 2 [ 1 ] = = str [ 1 ] and str 2 [ 2 ] = = str [ 2 ] then |
10 | print (str [ 1 ] .. ", " ..str 2 [ 1 ] .. ". " ..str [ 2 ] .. ", " ..str 2 [ 2 ] ) |
12 | if str [ 1 ] = = "Lights" and str [ 2 ] = = str 2 [ 2 ] then |
14 | for i, child in ipairs (o:GetChildren()) do |
15 | if child.ClassName = = 'Model' then |
16 | for i, lights in ipairs (child:GetChildren()) do |
17 | if lights.ClassName = = 'Part' then |
18 | lights.Transparency = 0 |
19 | lights.CanCollide = true |
20 | for i, pointlight in ipairs (lights:GetChildren()) do |
21 | if pointlight.ClassName = = "PointLight" then |
22 | pointlight.Brightness = 1.24 |
31 | if str [ 1 ] = = "Walls" and str 2 [ 1 ] = = "Walls" and str [ 2 ] = = str 2 [ 2 ] then |
33 | for i, child in ipairs (o:GetChildren()) do |
34 | if child.ClassName = = 'Part' then |
35 | if child.Name ~ = 'DropLocation' then |
36 | if child.Name = = 'Glass' then |
37 | child.Transparency = 0.4 |
39 | child.Transparency = 0 |
42 | child.CanCollide = true |
47 | if str [ 1 ] = = "Upgrade" and str [ 2 ] = = str 2 [ 2 ] then |
49 | for i, child in ipairs (o:GetChildren()) do |
50 | if child.ClassName = = 'Part' then |
51 | if child.Name ~ = 'DropLocation' then |
52 | child.Transparency = 0.65 |
53 | child.UpgradeScript.Disabled = false |
55 | child.CanCollide = false |
62 | for i, child in ipairs (o:GetChildren()) do |
63 | if child.ClassName = = 'Part' then |
64 | if child.Name ~ = 'DropLocation' then |
65 | child.Transparency = 0 |
67 | child.CanCollide = true |
70 | if script.Parent.Parent.Buyable:FindFirstChild(o.Name):FindFirstChild( 'Activated' ) then |
71 | script.Parent.Parent.Buyable:FindFirstChild(o.Name):FindFirstChild( 'Activated' ).Value = true |
73 | if t:FindFirstChild( "Unlocks" ) then |
74 | for i, button in ipairs (t.Unlocks:GetChildren()) do |
75 | button.Value.Head.Transparency = 0 |
76 | button.Value.Head.CanCollide = true |