"value of type string cannot be converted to a number" for i loop

Hi developers,

I’m making a piggy fanmade game, now i’m trying to make the bot countdown, but for some reason, this keeps happening:
Screenshot_10
I don’t know why, it keeps happening, i have a int value inside replicated storage and here is my script:

Server:

local RS = game:GetService("ReplicatedStorage")

local Timer = RS.Timer
local Status = Timer.Status

for count = 30, 0, -1 do
	-- Prints the current number the for loop is on
	Status.Value = "Piggy spawning"..count
	-- Wait 1 second
	task.wait(1)
end

Client:

while task.wait() do
	script.Parent.Text = game.ReplicatedStorage.Timer.Status.Value
end

Any help would be… Appreciated!!!

You’re setting an IntValue’s property to a string, make it a StringValue.

1 Like

IIRC Intvalue are for both string values and number values, but sure i’m gonna try

it worked first try lol didn’t knew string values were also for numbers

You can store a string into number/int values if the string can be converted into the proper type, I wouldn’t bet on that (for anything really). Always try and have the proper types for an object/API usage if possible.

1 Like

thanks but your first post solved it, thank you :slight_smile:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.