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

Help on this tool?

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

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)

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

2 comments

0

So, what's going to set the newMode parameter?

0

Are you new to functions? You'd do changeMode(1). Idiot.

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