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):

local prompt = script.Parent

prompt.Triggered:Connect(function(player)
    print("Activated") --this works

    local grappleAction = player.Character:FindFirstChild("Grapple"):FindFirstChild("shouldGrapple")
    grappleAction.Value = true --this works
    wait(1)
    grappleAction.Value = false --this works too
end)

Local Script(in startercharacterscripts):

local Action = script.shouldGrapple

Action.Changed:Connect(function(newvalue)
    print(newvalue)
end)

2 answers

Log in to vote
0
Answered by 4 years ago
prompt:GetPropertyChangedSignal("Value"):Connect(function(player)--will triger every time the value changes
    --your code here
end)
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
local BoolValue = --Bool Value--
Boolvalue.Changed:Connect(Function()
--Do stuff
end)

Answer this question