Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

My script is suppose to do a function if happen = true, but the first part of it isent working?

Asked by
danglt 185
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

001local vipid = 5785777
002 
003local Players = game:GetService("Players")
004 
005local ews = game.Workspace.EventModel
006local efolder = game.Lighting.EventModels
007local evalues = game.ReplicatedStorage.EventValues
008local tvalue = game.ReplicatedStorage.Values.tvalue
009local aevent = game.ReplicatedStorage.Values.aevent
010local acevent = game.ReplicatedStorage.Values.caevent
011local happen = game.ReplicatedStorage.Values.happen
012local aname = game.ReplicatedStorage.Values.ename
013local money = game.ReplicatedStorage.Values.money
014 
015local events = {"FloorIsLava","Event","BlackHole"}
View all 349 lines...
0
Your script requires that both acevent and happen are true, not just happen, check that acevent is true at the same time SerpentineKing 3885 — 6y
0
There is a spot for that... elseif happen.Value == true and acevent.Value == false then... Also as i stated if i put a print under the changed, It dosent print danglt 185 — 6y
1
I'd recommend learning how to use for loops. User#25115 0 — 6y
0
Are you sure that "Changed" is a valid event of "happen", since it should at least print if it is SerpentineKing 3885 — 6y
View all comments (2 more)
0
Yes, as if i change it manually it works danglt 185 — 6y
0
Good lord... if that isn't spaghetti code then I don't know what is. T0XN 276 — 6y

2 answers

Log in to vote
2
Answered by 6 years ago
Edited 6 years ago

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.

1--This is what you have, will never print "It changed!"
2myValue.Value = 5
3myValue.Changed:Connect(function()
4    print("It changed!")
5end)
1--This is what you should have, this will print "It changed!"
2myValue.Changed:Connect(function()
3    print("It changed!")
4end)
5myValue.Value = 5
0
I don't have access to studios right now because I'm on a school chromebook but when I get home ill see if it works and ill accept danglt 185 — 6y
Ad
Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

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.

001local vipid = 5785777
002 
003local Players = game:GetService("Players")
004 
005local ews = game.Workspace.EventModel
006local efolder = game.Lighting.EventModels
007local evalues = game.ReplicatedStorage.EventValues
008local tvalue = game.ReplicatedStorage.Values.tvalue
009local aevent = game.ReplicatedStorage.Values.aevent
010local acevent = game.ReplicatedStorage.Values.caevent
011local happen = game.ReplicatedStorage.Values.happen
012local aname = game.ReplicatedStorage.Values.ename
013local money = game.ReplicatedStorage.Values.money
014 
015local events = {"FloorIsLava","Event","BlackHole"}
View all 218 lines...

Answer this question