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

Help on this tool?

Asked by
Mystdar 352 Moderation Voter
10 years ago

I'm making a tool with multiple modes, would this be sufficent?

local mode = script.Parent.Mode

if mode.Value== 1 then 
    --Do stuff
elseif mode.Value == 2 then
    --do stuff
elseif mode.Value == 3 then
    -- do stuff
elseif mode.Value == 4 then
    -- do stuff
end

Would this cause a problem, in my tool? I'm still learning, I just posted this question as a precaution. Thanks

2 answers

Log in to vote
0
Answered by
Shawnyg 4330 Trusted Badge of Merit Snack Break Moderation Voter Community Moderator
10 years ago

What bobafett3544 attempted to say was, that you need a Changed event, or some sort of loop. I apologize if I misunderstood you, boba.

local mode = script.Parent.Mode

mode.Changed:connect(function()
    if (mode.Value == 1) then 
        --Do stuff
    elseif (mode.Value == 2) then
        --do stuff
    elseif (mode.Value == 3) then
        -- do stuff
    elseif (mode.Value == 4) then
        -- do stuff
    end
end)

Ad
Log in to vote
-1
Answered by 10 years ago

Yes, this would work, but of course, you'd need something to change the event. Here's a function that will change modes for you, so you don't have to type mode.Value all the time.

function changeMode(newMode)
local mode = script.Parent.Mode
mode.Value = newMode
end
0
So, what's going to set the newMode parameter? Shawnyg 4330 — 10y
0
Are you new to functions? You'd do changeMode(1). Idiot. bobafett3544 198 — 10y

Answer this question