NumberValue not being created in live game

I’m having an issue where this command isn’t working in live games only. In Studio, I can create the “Number” leaderstat perfectly fine, but not in a live game. (I published and made new servers just in case.) Every other data type works (string, integer, boolean) but not number. This is really strange to me.

Here’s what it looks like in a studio

And in a live game:

Here’s the code for the command.

MakeStat = {
			Prefix = Settings.Prefix;
			Commands = {"makestat";"leaderstat";"stat";};
			Args = {"player";"stat";"type(string/number/int/bool)";"value"};
			Filter = true;
			Description = "Add a statistic to <player> which displays in the leaderboard and can be changed with :setstat.\nUse the 'type' parameter to determine the type of stat.";
			AdminLevel = "Moderators";
			Function = function(plr,args)
				local sName = logic:get(plr,args[2],"") or "Stat"
				local sType = logic:get(plr,args[3],"") or "int"

				for i,v in pairs(logic:get(plr,args[1],plr)) do
					if not v:FindFirstChild("leaderstats") then
						local leaderstats = Instance.new("Folder",v)
						leaderstats.Name = "leaderstats"
					end
					local leaderstats = v:FindFirstChild("leaderstats")
					if leaderstats then
						if leaderstats:FindFirstChild("sName") then return end

						if sType == "string" then
							local stat = Instance.new("StringValue")
							stat.Name = sName
							stat.Value = logic:get(plr,args[4],"") or "Value"
							stat.Parent = leaderstats
						end
						if sType == "number" then
							print("type number detected")
							local stat = Instance.new("NumberValue")
							stat.Name = sName
							stat.Value = logic:get(plr,args[4],0) or 0
							stat.Parent = leaderstats
							print("made it")
						end
						if sType == "int" then
							local stat = Instance.new("IntValue")
							stat.Name = sName
							stat.Value = logic:get(plr,args[4],0) or 0
							stat.Parent = leaderstats
						end
						if sType == "bool" then
							local stat = Instance.new("BoolValue")
							stat.Name = sName
							stat.Value = logic:get(plr,args[4],true) or false
							stat.Parent = leaderstats
						end
					end
				end
			end
		};

The script that creates the number looks fine.

Where is the sType coming from?

Do you see the "type number detected” in the live game dev console?

image
Update: It’s randomly started working again in a live game?
It might have been a bug not too sure.

But this is solved now.

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