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

how to detect an intvalue's value if it changes?

Asked by
Catr899 12
2 years ago

For context when i press a button in starter gui

local function onActivated()
    if not debounce then
        debounce = true

        script.Parent.Parent.Sound:Play()


        local num = math.random(1, 4)

        -- below this actually works
        if num == 4 then
        workspace.Row1.Value = 4
        end


debounce = false
end
end
imageButton.Activated:Connect(onActivated)

This actually works as when i press it and the num is 4 then it will change the value to 4 but i cant detect if it changes to 4, ive tried.

script.Parent:GetPropertyChangedSignal("Value"):Connect(function()
    print(script.Parent.Value)
end)

thats what ive tried and i dont see anything wrong with it?

2 answers

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

CLIENT

You are changing it on client side for sure just use RemoteEvent :) bc it changes in client for the client its 4 but in the server its not.

Script(Inside ServerScriptService)

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local UrEventHere = ReplicatedStorage.UrEvenHere

UrEventHere.OnServerEvent:Connect(function(player, value)
    value.Value = value.Value + 1
end)

Local Script(ur localcsrcipt)

local function onActivated()
    if not debounce then
        debounce = true

        script.Parent.Parent.Sound:Play()


        local num = math.random(1, 4)

        -- below this actually works
        if num == 4 then
        event:FireServer(value)
        end


debounce = false
end
end
imageButton.Activated:Connect(onActivated)
0
how would i go about doing that? Catr899 12 — 2y
0
hmm do you need the actual code itself? acediamondn123 147 — 2y
0
hmm do you need the actual code itself? acediamondn123 147 — 2y
0
Ill just edit it hold on acediamondn123 147 — 2y
View all comments (3 more)
0
yes i need the script of recieveing the event and where i would put that script? Catr899 12 — 2y
0
nvm you solved it Catr899 12 — 2y
0
lol acediamondn123 147 — 2y
Ad
Log in to vote
0
Answered by 2 years ago

All values(IntValues, StringValues, etc) have a .Changed event

script.Parent.Changed:Connect(function(NewValue)
print(NewValue)
end)

'NewValue' is the value that the IntValue changes into

Answer this question