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

'for' initial value must be a number?

So I have this local timer script which functions when server fires the client. The issue is that studio thinks that the 'for' in the script must be some number.

function getdata(Plr,Secs)
	for s = Secs,0,-1 do
		wait(1)
		script.Parent.Secs.Text = s
	end
end

game.ReplicatedStorage.Special.GiveTimer.OnClientEvent:Connect(getdata)

1 comment

0

Please give me the full scripts to take a look. (all of them)

1 answer

Yes it needs to be a number, you're using Secs a variable (that isn't a number). You need to set it to a starting value (number). You can use a variable but it needs to be a number as the error stated.

Update: I just noticed you have 2 arguments to the function, but OnClientEvent doesn't provide the player argument since it's the server firing and the clients player is localplayer. Just remove the Plr from function getdata(Plr,Secs) and it will probably work. If you're firing the event with a number that number will be in Plr and Secs will be nil.

2 comments

0

At least show an example or the actual edited code for op. You're right, just show it.

0

His code works as it is, he just needs to use a correct value as an argument when calling the function / firing the event.

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