My script is suppose to do a function if happen = true, but the first part of it isent working?
Asked by
6 years ago Edited 6 years ago
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
003 | local Players = game:GetService( "Players" ) |
005 | local ews = game.Workspace.EventModel |
006 | local efolder = game.Lighting.EventModels |
007 | local evalues = game.ReplicatedStorage.EventValues |
008 | local tvalue = game.ReplicatedStorage.Values.tvalue |
009 | local aevent = game.ReplicatedStorage.Values.aevent |
010 | local acevent = game.ReplicatedStorage.Values.caevent |
011 | local happen = game.ReplicatedStorage.Values.happen |
012 | local aname = game.ReplicatedStorage.Values.ename |
013 | local money = game.ReplicatedStorage.Values.money |
015 | local events = { "FloorIsLava" , "Event" , "BlackHole" } |
032 | happen.Changed:Connect( function () |
033 | local apick = math.random( 1 , 3 ) |
034 | if happen.Value = = true and acevent.Value = = true then |
036 | if aevent.Value = = "FloorIsLava" then |
037 | aname.Value = "FloorIsLava" |
039 | acevent.Value = false |
041 | print ( "AFloorIsLava" ) |
042 | local fur = efolder.FloorIsLava.Furniture |
043 | local lava = efolder.FloorIsLava.Lava |
077 | lava.Parent = efolder.FloorIsLava |
078 | fur.Parent = efolder.FloorIsLava |
079 | for i, player in pairs (Players:GetPlayers()) do |
080 | if game:GetService( "MarketplaceService" ):UserOwnsGamePassAsync(player.UserId,vipid) then |
081 | player.leaderstats.Events.Value = player.leaderstats.Events.Value + 1 |
082 | player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + 50 + 20 |
083 | else player.leaderstats.Events.Value = player.leaderstats.Events.Value + 1 |
084 | player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + 50 |
088 | aname.Value = "Intermission" |
102 | elseif aevent.Value = = "BlackHole" then |
104 | aname.Value = "BlackHole" |
105 | acevent.Value = false |
109 | game.Workspace.Map.Ground.Velocity = Vector 3. new( 30 , 0 , 0 ) |
110 | local bh = game.Lighting.EventModels.BlackHole |
111 | bh.Parent = game.Workspace.EventModel |
112 | for i, player in pairs (Players:GetPlayers()) do |
113 | player.Character.Humanoid.PlatformStand = true |
146 | bh.Parent = game.Lighting.EventModels |
147 | game.Workspace.Map.Ground.Velocity = Vector 3. new( 0 , 0 , 0 ) |
148 | for i, player in pairs (Players:GetPlayers()) do |
149 | player.Character.Humanoid.PlatformStand = false |
150 | aname.Value = "Intermission" |
151 | for i, player in pairs (Players:GetPlayers()) do |
152 | if game:GetService( "MarketplaceService" ):UserOwnsGamePassAsync(player.UserId,vipid) then |
153 | player.leaderstats.Events.Value = player.leaderstats.Events.Value + 1 |
154 | player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + 50 + 20 |
155 | else player.leaderstats.Events.Value = player.leaderstats.Events.Value + 1 |
156 | player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + 50 |
159 | aname.Value = "Intermission" |
174 | elseif happen.Value = = true and acevent.Value = = false then |
177 | aname.Value = "BlackHole" |
178 | acevent.Value = false |
182 | game.Workspace.Map.Ground.Velocity = Vector 3. new( 30 , 0 , 0 ) |
183 | local bh = game.Lighting.EventModels.BlackHole |
184 | bh.Parent = game.Workspace.EventModel |
185 | for i, player in pairs (Players:GetPlayers()) do |
186 | player.Character.Humanoid.PlatformStand = true |
219 | bh.Parent = game.Lighting.EventModels |
220 | game.Workspace.Map.Ground.Velocity = Vector 3. new( 0 , 0 , 0 ) |
221 | for i, player in pairs (Players:GetPlayers()) do |
222 | player.Character.Humanoid.PlatformStand = false |
223 | aname.Value = "Intermission" |
225 | for i, player in pairs (Players:GetPlayers()) do |
226 | if game:GetService( "MarketplaceService" ):UserOwnsGamePassAsync(player.UserId,vipid) then |
227 | player.leaderstats.Events.Value = player.leaderstats.Events.Value + 1 |
228 | player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + 50 + 20 |
229 | else player.leaderstats.Events.Value = player.leaderstats.Events.Value + 1 |
230 | player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + 50 |
234 | aname.Value = "Intermission" |
246 | elseif apick = = 2 then |
248 | aname.Value = "FloorIsLava" |
250 | print ( "AFloorIsLava" ) |
251 | local fur = efolder.FloorIsLava.Furniture |
252 | local lava = efolder.FloorIsLava.Lava |
286 | lava.Parent = efolder.FloorIsLava |
287 | fur.Parent = efolder.FloorIsLava |
288 | for i, player in pairs (Players:GetPlayers()) do |
289 | if game:GetService( "MarketplaceService" ):UserOwnsGamePassAsync(player.UserId,vipid) then |
290 | player.leaderstats.Events.Value = player.leaderstats.Events.Value + 1 |
291 | player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + 50 + 20 |
292 | else player.leaderstats.Events.Value = player.leaderstats.Events.Value + 1 |
293 | player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + 50 |
297 | aname.Value = "Intermission" |
309 | elseif apick = = 3 then |
311 | aname.Value = "event3" |
313 | for i, player in pairs (Players:GetPlayers()) do |
314 | if game:GetService( "MarketplaceService" ):UserOwnsGamePassAsync(player.UserId,vipid) then |
315 | player.leaderstats.Events.Value = player.leaderstats.Events.Value + 1 |
316 | player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + 50 + 20 |
317 | else player.leaderstats.Events.Value = player.leaderstats.Events.Value + 1 |
318 | player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + 50 |
322 | aname.Value = "Intermission" |
334 | aname.Value = "Intermission" |