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

My script isn't working, and I think its because of tonumber. Anyone know why it isn't working?

I have been working on a clicker game, I have recently added a rebirth system which you can earn Tix from rebirthing. You can buy cases (More cases to open at a time) with this currency. But my script isn't working, and I got no errors, I think I may of used tonumber wrong

This is my serverscript

game.ReplicatedStorage.Remotes.Case.OnServerEvent:Connect(function(player, choice, cases)
	if choice == "Common" then
		if cases >= 1 then
			if cases >= _G["PlayerData"][player.UserId].Cases then
		if _G["PlayerData"][player.UserId].Kudos >= 400 then
			local data = _G["PlayerData"]
			_G["PlayerData"][player.UserId].Kudos = _G["PlayerData"][player.UserId].Kudos - 400
			local data = _G["PlayerData"]
			local randomize = math.floor(math.random(1,4))
			if randomize == 1 then
				data[player.UserId].Items[1].Own = data[player.UserId].Items[1].Own + 1*tonumber(cases)
				_G["PlayerData"][player.UserId].IdYouGot = data[player.UserId].Items[1].Id
				_G["PlayerData"][player.UserId].YouGot = data[player.UserId].Items[1].Name
				_G["PlayerData"][player.UserId].YouGotRAP = data[player.UserId].Items[1].Value
				_G["PlayerData"][player.UserId].ItemNum = 1
				return
			end

This is my LocalScript

fr.Cases.ScrollingFrame.Common.MouseButton1Click:Connect(function()
	local data = remotes.GetData:InvokeServer()
	fr.Cases.Visible = false
	fr.HowMuch.Visible = true -- Input how much cases
	fr.HowMuch.Case.Text = "Common"
end)

fr.HowMuch.Spin.MouseButton1Click:Connect(function()
		if tonumber(fr.HowMuch.TextBox.Text) >= 1 then
		game.ReplicatedStorage.Remotes.Case:FireServer(fr.HowMuch.Case.Text, tonumber(box.Text))
		fr.Cases.Visible = false
		fr.HowMuch.Visible = false
		fr.YouGot.Visible = true
		end
end)

1 answer

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