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

Variable being found unknown from function?

local function Round()
	local roundStartTime = tick()
end
	repeat
		local currentTime = tick()
		local TimeSinceGameStarted = currentTime - roundStartTime
		CreateExplosionPartCopy()
		wait(0.25)
	until TimeSinceGameStarted > onTime
	
	wait(offTime)
	
end

In the second block of code, you should see the "local TimeSinceGameStarted = currentTime - roundStartTime" line 3

My script isn't working and studio says roundStartTime is an unknown global, underlined in blue.

Thanks in advance

1 comment

0

First off, you cut your code and we cant see anything before repeat. also, scrap your Round function if thats all it does and put it before the repeat block. that should fix your problems. If you need more info as to why just ask me

1 answer

The problem here is that you made a function to declare the variable. Lukeb50 is correct, scrap it.

The problem here is one thing, functions wont run UNLESS IT IS CALLED. You never called it again, just defined it. Of course, you could just add a line of code to call it, but there is no point scince you never use the fuction again

Use functions when you want code to be repeated.

essentially, remove local function Round() and it's corresponding end

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