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

.Changed or GetPropertyChangedSignal("Value") doesn't fire?

Asked by 3 years ago
while wait() do
    if game.ReplicatedStorage.inRound:GetPropertyChangedSignal("Value") == false then
        print("false")
    end
    if game.ReplicatedStorage.inRound:GetPropertyChangedSignal("Value") == true then
        print("true")
    end
end

I've tried other methods as well but they won't fire at all. I've searched other threads as well but I can't find the answer. Any help is appreciated, thanks.

2 answers

Log in to vote
0
Answered by
Soban06 410 Moderation Voter
3 years ago

Please provide explanation with your answers. Simply posting code does not spread knowledge of integral scripting processes which helps people understand the logic and reasoning behind your answer.

In your above scenario, why don't you just do:

while wait() do
    if game.ReplicatedStorage.inRound.Value == false then
        print("false")
    end
    if game.ReplicatedStorage.inRound.Value == true then
        print("true")
    end
end

Hope it helps

0
Thanks for the reply. I tried your code but it doesn't work either. I turned the inRound.Value on and off in the game but it just keeps printing "false". vNLegacy 9 — 3y
0
Were you changing the value on and off locally and is the script a server script? If you are changing the value locally (Client side), and the script is on the server's side, it might be printing what the server sees: false. ChristianTRPOC 64 — 3y
0
Well I play tested it. The inRound is in the RepStorage, so when I play tested I just turned it off and on. I don't know if that's changing it locally, and yes the it's a server script. vNLegacy 9 — 3y
0
Press play/play here, in "Home" or "Test", find "Current: Client", press it and it should say Current: Server. Now try changing the value. ChristianTRPOC 64 — 3y
View all comments (2 more)
0
Make sure you are changing the value from the Server and not from the client as that won't work. As @ChristianTRPOC said. Play the game and click on, Current: Client. Now it should say Current: Server and now go to Replicated Storage and change the value. Soban06 410 — 3y
0
Thank you guys so much that was the problem! I just wasnt running from the server! vNLegacy 9 — 3y
Ad
Log in to vote
0
Answered by 3 years ago

GetPropertyChangedSignal() isn't being used correctly. The great thing about this is that you don't need a loop at all. This function triggers a watch on a server event, in this case "Value" being changed.

Try this:

game.ReplicatedStorage.inRound:GetPropertyChangedSignal("Value"):Connect(function(Value)
    if Value then
        print("false")
    else
        print("true")
    end
end)

or simply:

game.ReplicatedStorage.inRound:GetPropertyChangedSignal("Value"):Connect(function(Value)
    print(Value)  -- Since Value will automatically be casted into a string
end)
0
Your game will also run faster, since you're not running an infinite loop which takes resources nikoviking 236 — 3y
0
Thanks for the reply. I tried this but it unfortunately still doesn't work. vNLegacy 9 — 3y
0
Was there any error given? It worked when I tested it. Did you write :Connect(function(Value ... ? nikoviking 236 — 3y
0
yeah thank you! it works the problem was I just wasnt running from the server. I ran it with the client vNLegacy 9 — 3y
0
sorry I didn't choose your answer! It definitely made my code a lot more effiecient, though. vNLegacy 9 — 3y

Answer this question