My script will run and the first part will work changing tvalue but for some reason after that when i make happen = true after that it makes it true but then the happen.Changed function doesent activate, I have no idea why.
I put a print under the changed function and I got no print, so the problem is the Changed Function not working in the beginning
local vipid = 5785777 local Players = game:GetService("Players") local ews = game.Workspace.EventModel local efolder = game.Lighting.EventModels local evalues = game.ReplicatedStorage.EventValues local tvalue = game.ReplicatedStorage.Values.tvalue local aevent = game.ReplicatedStorage.Values.aevent local acevent = game.ReplicatedStorage.Values.caevent local happen = game.ReplicatedStorage.Values.happen local aname = game.ReplicatedStorage.Values.ename local money = game.ReplicatedStorage.Values.money local events = {"FloorIsLava","Event","BlackHole"} tvalue.Value = 5 --------------------------- PROBLEM STARTS HERE wait(1) tvalue.Value = 4 wait(1) tvalue.Value = 3 wait(1) tvalue.Value = 2 wait(1) tvalue.Value = 1 wait(1) happen.Value = true wait() happen.Changed:Connect(function() local apick = math.random(1,3) if happen.Value == true and acevent.Value == true then happen.Value = false if aevent.Value == "FloorIsLava" then aname.Value = "FloorIsLava" aevent.Value = "" acevent.Value = false wait() print("AFloorIsLava") local fur = efolder.FloorIsLava.Furniture local lava = efolder.FloorIsLava.Lava fur.Parent = ews tvalue.Value = 15 wait(1) tvalue.Value = 14 wait(1) tvalue.Value = 13 wait(1) tvalue.Value = 12 wait(1) tvalue.Value = 11 wait(1) tvalue.Value = 10 wait(1) tvalue.Value = 9 wait(1) tvalue.Value = 8 lava.Parent = ews wait(1) tvalue.Value = 7 wait(1) tvalue.Value = 6 wait(1) tvalue.Value = 5 wait(1) tvalue.Value = 4 wait(1) tvalue.Value = 3 wait(1) tvalue.Value = 2 wait(1) tvalue.Value = 1 wait(1) tvalue.Value = 0 lava.Parent = efolder.FloorIsLava fur.Parent = efolder.FloorIsLava for i, player in pairs(Players:GetPlayers()) do if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId,vipid) then player.leaderstats.Events.Value = player.leaderstats.Events.Value + 1 player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + 50 + 20 else player.leaderstats.Events.Value = player.leaderstats.Events.Value + 1 player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + 50 end end aname.Value = "Intermission" tvalue.Value = 5 wait(1) tvalue.Value = 4 wait(1) tvalue.Value = 3 wait(1) tvalue.Value = 2 wait(1) tvalue.Value = 1 wait(1) happen.Value = true elseif aevent.Value == "BlackHole" then aevent.Value = "" aname.Value = "BlackHole" acevent.Value = false wait() print("BlackHole") happen.Value = false game.Workspace.Map.Ground.Velocity = Vector3.new(30,0,0) local bh = game.Lighting.EventModels.BlackHole bh.Parent = game.Workspace.EventModel for i, player in pairs(Players:GetPlayers()) do player.Character.Humanoid.PlatformStand = true end tvalue.Value = 15 wait(1) tvalue.Value = 14 wait(1) tvalue.Value = 13 wait(1) tvalue.Value = 12 wait(1) tvalue.Value = 11 wait(1) tvalue.Value = 10 wait(1) tvalue.Value = 9 wait(1) tvalue.Value = 8 wait(1) tvalue.Value = 7 wait(1) tvalue.Value = 6 wait(1) tvalue.Value = 5 wait(1) tvalue.Value = 4 wait(1) tvalue.Value = 3 wait(1) tvalue.Value = 2 wait(1) tvalue.Value = 1 wait(1) tvalue.Value = 0 bh.Parent = game.Lighting.EventModels game.Workspace.Map.Ground.Velocity = Vector3.new(0,0,0) for i, player in pairs(Players:GetPlayers()) do player.Character.Humanoid.PlatformStand = false aname.Value = "Intermission" for i, player in pairs(Players:GetPlayers()) do if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId,vipid) then player.leaderstats.Events.Value = player.leaderstats.Events.Value + 1 player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + 50 + 20 else player.leaderstats.Events.Value = player.leaderstats.Events.Value + 1 player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + 50 end aname.Value = "Intermission" tvalue.Value = 5 wait(1) tvalue.Value = 4 wait(1) tvalue.Value = 3 wait(1) tvalue.Value = 2 wait(1) tvalue.Value = 1 wait(1) happen.Value = true end end end elseif happen.Value == true and acevent.Value == false then if apick == 1 then aevent.Value = "" aname.Value = "BlackHole" acevent.Value = false wait() print("BlackHole") happen.Value = false game.Workspace.Map.Ground.Velocity = Vector3.new(30,0,0) local bh = game.Lighting.EventModels.BlackHole bh.Parent = game.Workspace.EventModel for i, player in pairs(Players:GetPlayers()) do player.Character.Humanoid.PlatformStand = true end tvalue.Value = 15 wait(1) tvalue.Value = 14 wait(1) tvalue.Value = 13 wait(1) tvalue.Value = 12 wait(1) tvalue.Value = 11 wait(1) tvalue.Value = 10 wait(1) tvalue.Value = 9 wait(1) tvalue.Value = 8 wait(1) tvalue.Value = 7 wait(1) tvalue.Value = 6 wait(1) tvalue.Value = 5 wait(1) tvalue.Value = 4 wait(1) tvalue.Value = 3 wait(1) tvalue.Value = 2 wait(1) tvalue.Value = 1 wait(1) tvalue.Value = 0 bh.Parent = game.Lighting.EventModels game.Workspace.Map.Ground.Velocity = Vector3.new(0,0,0) for i, player in pairs(Players:GetPlayers()) do player.Character.Humanoid.PlatformStand = false aname.Value = "Intermission" end for i, player in pairs(Players:GetPlayers()) do if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId,vipid) then player.leaderstats.Events.Value = player.leaderstats.Events.Value + 1 player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + 50 + 20 else player.leaderstats.Events.Value = player.leaderstats.Events.Value + 1 player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + 50 end end aname.Value = "Intermission" tvalue.Value = 5 wait(1) tvalue.Value = 4 wait(1) tvalue.Value = 3 wait(1) tvalue.Value = 2 wait(1) tvalue.Value = 1 wait(1) happen.Value = true elseif apick == 2 then happen.Value = false aname.Value = "FloorIsLava" print("FloorIsLava") print("AFloorIsLava") local fur = efolder.FloorIsLava.Furniture local lava = efolder.FloorIsLava.Lava fur.Parent = ews tvalue.Value = 15 wait(1) tvalue.Value = 14 wait(1) tvalue.Value = 13 wait(1) tvalue.Value = 12 wait(1) tvalue.Value = 11 wait(1) tvalue.Value = 10 wait(1) tvalue.Value = 9 wait(1) tvalue.Value = 8 lava.Parent = ews wait(1) tvalue.Value = 7 wait(1) tvalue.Value = 6 wait(1) tvalue.Value = 5 wait(1) tvalue.Value = 4 wait(1) tvalue.Value = 3 wait(1) tvalue.Value = 2 wait(1) tvalue.Value = 1 wait(1) tvalue.Value = 0 lava.Parent = efolder.FloorIsLava fur.Parent = efolder.FloorIsLava for i, player in pairs(Players:GetPlayers()) do if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId,vipid) then player.leaderstats.Events.Value = player.leaderstats.Events.Value + 1 player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + 50 + 20 else player.leaderstats.Events.Value = player.leaderstats.Events.Value + 1 player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + 50 end end aname.Value = "Intermission" tvalue.Value = 5 wait(1) tvalue.Value = 4 wait(1) tvalue.Value = 3 wait(1) tvalue.Value = 2 wait(1) tvalue.Value = 1 wait(1) happen.Value = true elseif apick == 3 then happen.Value = false aname.Value = "event3" print("event3") for i, player in pairs(Players:GetPlayers()) do if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId,vipid) then player.leaderstats.Events.Value = player.leaderstats.Events.Value + 1 player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + 50 + 20 else player.leaderstats.Events.Value = player.leaderstats.Events.Value + 1 player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + 50 end end aname.Value = "Intermission" tvalue.Value = 5 wait(1) tvalue.Value = 4 wait(1) tvalue.Value = 3 wait(1) tvalue.Value = 2 wait(1) tvalue.Value = 1 wait(1) happen.Value = true aname.Value = "Intermission" tvalue.Value = 5 wait(1) tvalue.Value = 4 wait(1) tvalue.Value = 3 wait(1) tvalue.Value = 2 wait(1) tvalue.Value = 1 wait(1) happen.Value = true end end end)
The Changed event hasn't been registered yet by your code, and therefore never runs. You have to move it before you change the value if you want it to run.
--This is what you have, will never print "It changed!" myValue.Value = 5 myValue.Changed:Connect(function() print("It changed!") end)
--This is what you should have, this will print "It changed!" myValue.Changed:Connect(function() print("It changed!") end) myValue.Value = 5
This isnt an answer i just wanted to fix your gross indention and add some basic for loops. On line 108 i think there was an extra end, i commented it out.
local vipid = 5785777 local Players = game:GetService("Players") local ews = game.Workspace.EventModel local efolder = game.Lighting.EventModels local evalues = game.ReplicatedStorage.EventValues local tvalue = game.ReplicatedStorage.Values.tvalue local aevent = game.ReplicatedStorage.Values.aevent local acevent = game.ReplicatedStorage.Values.caevent local happen = game.ReplicatedStorage.Values.happen local aname = game.ReplicatedStorage.Values.ename local money = game.ReplicatedStorage.Values.money local events = {"FloorIsLava","Event","BlackHole"} tvalue.Value = 5 for i = 1, 5 do tvalue.Value = tvalue.Value -1 --------------------------- PROBLEM STARTS HERE wait(1) end happen.Value = true wait() happen.Changed:Connect(function() local apick = math.random(1,3) if happen.Value == true and acevent.Value == true then happen.Value = false if aevent.Value == "FloorIsLava" then aname.Value = "FloorIsLava" aevent.Value = "" acevent.Value = false wait() print("AFloorIsLava") local fur = efolder.FloorIsLava.Furniture local lava = efolder.FloorIsLava.Lava fur.Parent = ews tvalue.Value = 15 wait(1) for i = 1, 7 do tvalue.Value = tvalue.Value - 1 wait(1) end lava.Parent = ews for i = 1, 8 do tvalue.Value = tvalue.Value - 1 wait(1) end lava.Parent = efolder.FloorIsLava fur.Parent = efolder.FloorIsLava for i, player in pairs(Players:GetPlayers()) do if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId,vipid) then player.leaderstats.Events.Value = player.leaderstats.Events.Value + 1 player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + 50 + 20 else player.leaderstats.Events.Value = player.leaderstats.Events.Value + 1 player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + 50 end end aname.Value = "Intermission" tvalue.Value = 5 for i = 1, 5 do tvalue.Value = tvalue.Value - 1 wait(1) end happen.Value = true elseif aevent.Value == "BlackHole" then aevent.Value = "" aname.Value = "BlackHole" acevent.Value = false wait() print("BlackHole") happen.Value = false game.Workspace.Map.Ground.Velocity = Vector3.new(30,0,0) local bh = game.Lighting.EventModels.BlackHole bh.Parent = game.Workspace.EventModel for i, player in pairs(Players:GetPlayers()) do player.Character.Humanoid.PlatformStand = true end tvalue.Value = 15 for i = 1, 15 do tvalue.Value = tvalue.Value - 1 wait(1) end bh.Parent = game.Lighting.EventModels game.Workspace.Map.Ground.Velocity = Vector3.new(0,0,0) for i, player in pairs(Players:GetPlayers()) do player.Character.Humanoid.PlatformStand = false aname.Value = "Intermission" if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId,vipid) then player.leaderstats.Events.Value = player.leaderstats.Events.Value + 1 player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + 50 + 20 else player.leaderstats.Events.Value = player.leaderstats.Events.Value + 1 player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + 50 end aname.Value = "Intermission" tvalue.Value = 5 for i = 1, 5 do tvalue.Value = tvalue.Value - 1 wait(1) end happen.Value = true end --end elseif happen.Value == true and acevent.Value == false then if apick == 1 then aevent.Value = "" aname.Value = "BlackHole" acevent.Value = false wait() print("BlackHole") happen.Value = false game.Workspace.Map.Ground.Velocity = Vector3.new(30,0,0) local bh = game.Lighting.EventModels.BlackHole bh.Parent = game.Workspace.EventModel for i, player in pairs(Players:GetPlayers()) do player.Character.Humanoid.PlatformStand = true end tvalue.Value = 15 for i = 1, 15 do tvalue.Value = tvalue.Value - 1 wait(1) end bh.Parent = game.Lighting.EventModels game.Workspace.Map.Ground.Velocity = Vector3.new(0,0,0) for i, player in pairs(Players:GetPlayers()) do player.Character.Humanoid.PlatformStand = false aname.Value = "Intermission" end for i, player in pairs(Players:GetPlayers()) do if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId,vipid) then player.leaderstats.Events.Value = player.leaderstats.Events.Value + 1 player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + 50 + 20 else player.leaderstats.Events.Value = player.leaderstats.Events.Value + 1 player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + 50 end end aname.Value = "Intermission" tvalue.Value = 5 for i = 1, 5 do tvalue.Value = tvalue.Value - 1 wait(1) end happen.Value = true elseif apick == 2 then happen.Value = false aname.Value = "FloorIsLava" print("FloorIsLava") print("AFloorIsLava") local fur = efolder.FloorIsLava.Furniture local lava = efolder.FloorIsLava.Lava fur.Parent = ews tvalue.Value = 15 wait(1) for i = 1, 7 do tvalue.Value = tvalue.Value - 1 wait(1) end lava.Parent = ews for i = 1, 8 do tvalue.Value = tvalue.Value - 1 wait(1) end lava.Parent = efolder.FloorIsLava fur.Parent = efolder.FloorIsLava for i, player in pairs(Players:GetPlayers()) do if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId,vipid) then player.leaderstats.Events.Value = player.leaderstats.Events.Value + 1 player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + 50 + 20 else player.leaderstats.Events.Value = player.leaderstats.Events.Value + 1 player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + 50 end end aname.Value = "Intermission" tvalue.Value = 5 for i = 1, 5 do tvalue.Value = tvalue.Value - 1 wait(1) end happen.Value = true elseif apick == 3 then happen.Value = false aname.Value = "event3" print("event3") for i, player in pairs(Players:GetPlayers()) do if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId,vipid) then player.leaderstats.Events.Value = player.leaderstats.Events.Value + 1 player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + 50 + 20 else player.leaderstats.Events.Value = player.leaderstats.Events.Value + 1 player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + 50 end end aname.Value = "Intermission" tvalue.Value = 5 for i = 1, 5 do tvalue.Value = tvalue.Value - 1 wait(1) end happen.Value = true aname.Value = "Intermission" tvalue.Value = 5 for i = 1, 5 do tvalue.Value = tvalue.Value - 1 wait(1) end happen.Value = true end end end)