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

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

Asked by 6 years ago

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

Log in to vote
0
Answered by 6 years ago

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.)

0
Sorry I didn't mean you're connecting the function wrong, I meant that you're not using the Changed event correctly. Ultimate_Piccolo 201 — 6y
Ad

Answer this question