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

I am getting "Attempt to index function with 'Value' on this script, why?

I don't know why this is happening since I've done this before, I have tried replacing ""..i.." with ""..i, but with no luck. Can someone please help me here?

My script:

local function Timer()
	while true do
		Status.Value = "Waiting for 2 players..."
		
		repeat wait() until game.Players.NumPlayers >= 1
		
		for i = intermissionLength, 1, -1 do
			InRound.Value = false
			wait(1)
			Status.Value = "Intermission"
			Timer.Value = ""..i..""
		end
		for i = roundLength, 1, -1 do
			InRound.Value = true
			wait(1)
			Status.Value = "Current round"
			Timer.Value = ""..i.." seconds left!"
		end
	end
end

spawn(Timer)

1 answer

I'm assuming Timer on line 11 is a variable. If that's the case, then you are creating two variables with the same name, the newer one being the function Timer, overwriting the old Timer variable. This makes the script think you are trying to index a function with a property. The solution is to rename one of these variables, I suggest renaming Timer to StartTimer.

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