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

What is a function or code that constantly checks if something like a value has been change?

A bit of context - my code is made so that when a intvalue in server storage is changed a huge event happens. However I have been finding that the code will not work unless the intvalue has already been changed and will not respond if the value is changed a second after. For example-


if game.ServerStorage.Folder.prep.Value == 1 then
	game.ServerStorage.Folder.prep.Value = 0
if game.ServerStorage.Folder.prep.Value == 0 then
	wait(5)
while true do
local origin = game.ReplicatedStorage.Face:Clone()
	origin.Parent = game.Workspace.PArty.Sunflower
	wait(0.05)
	origin:Destroy()
end

The script above would work but it would stop if the first one waits for even one second. In conclusion my scripts only work if a value is changed before it starts its code. I would really appreciate it if someone could instruct or direct to function/code that could check for the value to change constantly. Thank you, any help/suggestions is appreciated.

1 answer

✓ Accepted answer
game.ServerStorage.Folder.prep.Value.Changed:Connect(function()

2 comments

0

An error appears ,it says attempt to index field 'Value'(a number value)

0

delete the value

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