Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

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)

7 comments

0

how would i go about doing that?

0

hmm do you need the actual code itself?

0

hmm do you need the actual code itself?

0

Ill just edit it hold on

0

yes i need the script of recieveing the event and where i would put that script?

0

nvm you solved it

0

lol

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

This discussion is preserved as it was. New answers, comments, and votes are closed.