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

how to make a function happen when a variable is certian is set?

Asked by 4 years ago
Edited 4 years ago

I've been working on a game and always get errors on this, youtube doesnt work.

level=1(function()
    script.Parent.Text="You Have Reached A Beginner Rank Keep Working To Level Up More Until Amature; Level: 15"
end)
0
please post the entire script. mightydifferent 85 — 4y
0
that is Donald_TrumpREAL1238 -27 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

The easiest way is to set the variable inside the function, and then call the function when you want to set the level variable, like so:

-- Call this function when you want to set level
local function SetLevel(newLevel)
    level = newLevel
    script.Parent.Text="You Have Reached A Beginner Rank Keep Working To Level Up More Until Amature; Level: 15"
end

-- Calling the function
SetLevel(1)
0
so does the function activate when the variable is 1? Donald_TrumpREAL1238 -27 — 4y
Ad

Answer this question