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

How do I make a function yield if its requirements hasn't been met ?

Asked by 4 years ago

What I am trying to do here is if Baseplates transparency is over then I will print its gone

function WaitForSomething()
    if game.Workspace.Baseplate.Transparency > .5 then

    end


end


if WaitForSomething() then

print('Gone')

end

1 answer

Log in to vote
1
Answered by
Prestory 1395 Moderation Voter
4 years ago
Edited 4 years ago

You could use :GetPropertyChangedSignal which would fire when what ever you put between the Speech Marks has changed.

For example below i have placed "Transparency" between the speech marks which makes the script wait for the Transparency of the Base plate to change then Fires the WaitForSomething Function

But you have to make sure that it is a Property.

function WaitForSomething()
if game.Workspace.Baseplate.Transparency > .5 then
    print("Gone")
    end
end

workspace.Baseplate:GetPropertyChangedSignal("Transparency"):Connect(WaitForSomething)
Ad

Answer this question