I don't know how the fix script

I have a script for an autoclicker and there is a class in the leaderstats, it is located in the string value and I don’t know how to fix the problem

1 Like
local MarketPlaceService = game:GetService("MarketplaceService")
local id = 251630884

local cooldown = 3
local ToolName = 'Punch'

local function boost(strength, player, multipliers)
	while task.wait(cooldown) do
		local n = multipliers[1].Value
		local owns = MarketPlaceService:UserOwnsGamePassAsync(player.UserId, 257905319)

		for i, v in ipairs(multipliers) do
			if i == 1 then continue end
			n *= v.Value
		end

		if MarketPlaceService:UserOwnsGamePassAsync(player.UserId, 257904902) then
			n *= 2    
		end

		if player.Character and player.Character:FindFirstChild(ToolName) then
			strength.Value += owns and n*2 or n
		end
	end
end

local function onPlayerAdded(player)
	local strength = player:WaitForChild("Strength")
	local multipliers = {
		player:WaitForChild("ZoneMulti"),
		player:WaitForChild("Multi"),
		player:WaitForChild("BestFusion"):WaitForChild("FusionMulti"),
                player.leaderstats:WaitForChild("Class")
	}

	if MarketPlaceService:UserOwnsGamePassAsync(player.UserId, id) then
		boost(strength, player, multipliers)
	end
end

MarketPlaceService.PromptGamePassPurchaseFinished:Connect(function(player, ido, purchased)
	if purchased and id == ido then
		local strength = player:WaitForChild("Strength")
		local multipliers = {
			player:WaitForChild("ZoneMulti"),
			player:WaitForChild("Multi"),
			player:WaitForChild("BestFusion"):WaitForChild("FusionMulti"),
                        player.leaderstats:WaitForChild("Class")
		}

		boost(strength, player, multipliers)
	end
end)

game.Players.PlayerAdded:Connect(onPlayerAdded)

Could you provide more details? What is the error/problem you’re facing?

ServerScriptService.AutoClicker:14: attempt to perform arithmetic (mul) on number and string - Server - AutoClicker:14

Seems like this is happening due to one of the multipliers in the multipliers table being a StringValue instead of a NumberValue. Make sure all of the following are of type NumberValue:

image

This class is he string value I don’t want to remove it from this script, help me fix it

Okay, instead of

		for i, v in ipairs(multipliers) do
			if i == 1 then continue end
			n *= v.Value
		end

Replace it with

		for i, v in ipairs(multipliers) do
			if i == 1 then continue end
			if v:IsA("NumberValue") then
				n *= v.Value
			end
		end

This fixed the problem, but now I have the following problem.

I would like all the multiplayers to be in this script, I have them in this script but half of them don’t work

So look, I get 5k from the tool and I get 1k from this script.

Can you help? I don’t know how to fix this.

local MarketPlaceService = game:GetService("MarketplaceService")
local event = game.ReplicatedStorage.AddStat
local alertClients = game.ReplicatedStorage.ServerMessage

local gamepassId = 257905319
local strengthPass = 257904902
local endPass = 257904475

local function ownsgamepass(userId, gamepassId)
	local ownsGamepass = false
	local success, res = pcall(function()
		ownsGamepass = MarketPlaceService:UserOwnsGamePassAsync(userId, gamepassId)
	end)
	return success and ownsGamepass
end

event.OnServerEvent:Connect(function(player, stat, val, op)
	print(stat)
	local value = val
	local owns = ownsgamepass(player.UserId, gamepassId)
	local playerStat = player:FindFirstChild(stat) or player.leaderstats:FindFirstChild(stat)
	-- where before the or you’re looking for the stat and after the or you’re looking for a class

	if not playerStat then
		warn("Stat not found for player:", player.Name, "Stat:", stat)
		return
	end

	if (stat == "Strength" and ownsgamepass(player.UserId, strengthPass))
		or (stat == "Endurance" and ownsgamepass(player.UserId, endPass)) then
		value *= 2
	end

	if op == "+" then
		if player.Character and player.Character:FindFirstChild("SafeZone") and player.Character.SafeZone.Start.Value == true then
			playerStat.Value += value
		end
		if owns then
			playerStat.Value += value * 2
		else
			playerStat.Value += value
		end
	elseif op == "set" then
		if typeof(value) == "number" and owns and not string.match(stat, "Multi") then
			playerStat.Value = value * 2
		else
			playerStat.Value = value
		end
		if string.match(val, "Class") then
			alertClients:FireAllClients(player.Name.." has ranked up to "..value.."!") -- Handle class purchase logic here
		end
	end
end)

This script is responsible for all the multipliers, that is, all that is needed here is

You’re just pasting different scripts to be fixed every minute, this is too much for me. Maybe someone else can help you with your problems. Looks like you’re using AI-generated code to me.

The multiplier from the class with the game pass and other multipliers, but in that script it doesn’t work and I don’t know what exactly doesn’t work

No, I wrote this script myself.

The script that I sent you is an add stat, that is, an addition, and I would like it to be in the script that created the topic script

So you want to combine 2 scripts?

I would like the whole multiplier to be in the autoclicker that we fixed

I think you should look into modular programming, you wouldn’t run into any of these issues in the first place. ModuleScript will be your life saver.