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

Variable won't change when client receives event?

I have the server firing all clients every second to change the value of a TextLabel on screen, and the intermissionTime variable changing every time the client is fired, but for some reason, the intermissionTime variable only changes once, to 29. My code is below. Thanks!

local timer = script.Parent
local intermissionTimer = game.ReplicatedStorage.Events.ChangeTimeIntermission

local intermissionTime = 30

intermissionTimer.OnClientEvent:Connect(function()
	
	local intermissionTime = intermissionTime - 1
	timer.Text = intermissionTime
	print("client: received server fired, time left is "..intermissionTime)
	
end)

1 comment

0

Just add a while loop to get it to repeat.

1 answer

✓ Accepted answer

It was me. For some reason, taking away the "local" on line 08 made it work.

2 comments

0

The Variable was already defined. When you put local the variable gets defined. Putting no local will reference a variable that was already made like the "IntermissionTime" Variable you made up above in your script!!! <:D>!

0

mark your question as Answered by Yourself

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