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

How can I detect when a boolvalue's value is changed?

Asked by 4 years ago

Hi! I want to print something whenever a boolvalue's value is changed but I'm having problems. Help?

Script(in workspace):

01local prompt = script.Parent
02 
03prompt.Triggered:Connect(function(player)
04    print("Activated") --this works
05 
06    local grappleAction = player.Character:FindFirstChild("Grapple"):FindFirstChild("shouldGrapple")
07    grappleAction.Value = true --this works
08    wait(1)
09    grappleAction.Value = false --this works too
10end)

Local Script(in startercharacterscripts):

1local Action = script.shouldGrapple
2 
3Action.Changed:Connect(function(newvalue)
4    print(newvalue)
5end)

2 answers

Log in to vote
0
Answered by 4 years ago
1prompt:GetPropertyChangedSignal("Value"):Connect(function(player)--will triger every time the value changes
2    --your code here
3end)
0
Still doesn't print anything. bruceywayne 35 — 4y
0
how u changing the boolvalue? Pitched_mobile 191 — 4y
0
Exactly like in the script I posted. I double-checked the value in-game and it does change when it should. But for some reason the local script inside the player does not print when the value changes. bruceywayne 35 — 4y
0
u cant change values with scripts in the workspace Pitched_mobile 191 — 4y
View all comments (3 more)
0
It doesn't print anything even when I change it from the server. bruceywayne 35 — 4y
0
because the boolvalue never changes Pitched_mobile 191 — 4y
0
I just said I'm changing it from the server. It does change and it does not print anything like it should. bruceywayne 35 — 4y
Ad
Log in to vote
0
Answered by 4 years ago
1local BoolValue = --Bool Value--
2Boolvalue.Changed:Connect(Function()
3--Do stuff
4end)

Answer this question