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

How would I make a function that checks if a value of something is below 0?

Ive tried using

function CheckToBreak()
if script.Parent.ValueA.Value <= 0 then
    script.Parent.ValueA.Value = 9999999
	local Clone1 = game.ReplicatedStorage.Parts.Part:Clone()
	local Clone2 = game.ReplicatedStorage.Parts.Part:Clone()
	Clone1.Position = Vector3.new(script.Parent.Position)
	Clone1.Position = Vector3.new(script.Parent.Position)
	Clone2.Position = Vector3.new(script.Parent.Position)
	Clone2.Position = Vector3.new(script.Parent.Position)
	script.Parent:Destroy()
	else print(no)
end

script.Parent.ValueA.Value.Changed:connect(CheckValue)

But it doesnt work. Help?

1 answer

You're connecting the function wrong, you're doing

script.Parent.ValueA.Value.Changed:connect(CheckValue)

The proper way is to just do

script.Parent.ValueA.Changed:Connect(CheckValue)

It detects when the value of "ValueA" changes, not when the value of the value of "ValueA" changes (if you understand what I mean.)

1 comment

0

Sorry I didn't mean you're connecting the function wrong, I meant that you're not using the Changed event correctly.

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