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

Changed:connect() is not working on a number value?

Im trying to make a script that detects if the number value I have provided it with is above a certain number. This is the code:

game.Workspace.gameCore.Data.coreTemp.Value.Changed:connect(function(alert)
if game.Workspace.gameCore.Data.coreTemp.Value > 2400 and script.played.Value == false then
		-- Oh noe! Its above the threshhold!
elseif game.Workspace.gameCore.Data.coreTemp.Value <= 2400 then
		-- Phew. Its back to normal.
end	
end)

Ive checked and the locations of everything is correct. Im not sure why its not working. The output is:

Attempt to index field 'Value' (A number value)

1 answer

✓ Accepted answer

Your error is most likely that you are calling on the specified value when it's changed, and not the entire string itself.

Here is the wiki description of .Changed: **Description**: Fires when a property of the object changes.

It fires when the property of an object changes, so if you try to fire the property, there is no property to it.

See if this script helps you out.

game.Workspace.gameCore.Data.coreTemp.Changed:connect(function(alert)
if game.Workspace.gameCore.Data.coreTemp.Value > 2400 and script.played.Value == false then
        -- Oh noe! Its above the threshhold!
elseif game.Workspace.gameCore.Data.coreTemp.Value <= 2400 then
        -- Phew. Its back to normal.
end 
end)

1 comment

0

Yup, it worked. That makes so much more sense. Thanks!

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