Coin Tool Not Working! Help Needed

You can write your topic however you want, but you need to answer these questions:
I really need the leaderstats tool clicker to work for my pet system.
So, I had tried to click the tool to get “Taps” as a leaderstats, but I changed something before and didn’t know what went wrong.
image
and
image
Data problem was on line 189, and the Pet error was on line 24.
Here’s the script that went wrong for the Pets errors:

local debounce = false

function getMultiplier(Player, multiplierName)
	local Multi = 0.5
script.GetClick.OnServerEvent:Connect(function(plr)
	if not debounce then
		debounce = true
		local leaderstats = plr:WaitForChild("leaderstats")
		leaderstats.Taps.Value = leaderstats.Taps.Value + 2 * getMultiplier(plr, "Multiplier1")
		wait(0.1)
		debounce = false
	end
end) 

And here is the script where the Data error sent me:

local RS = game.ReplicatedStorage
local MS = game:GetService("MarketplaceService")

function GetFolderFromPetID(Player, PetID)
	for i,v in pairs(Player.Pets:GetChildren()) do
		if v.PetID.Value == PetID then
			return v
		end
	end
	return nil
end

function GetPointOnCircle(CircleRadius, Degrees)
    return Vector3.new(math.cos(math.rad(Degrees)) * CircleRadius, 1, math.sin(math.rad(Degrees))* CircleRadius)
end

function GetAllOfType(Player, PetName, Type)
	local Pets = {}
	for i,v in pairs(Player.Pets:GetChildren()) do
		if v.Name == PetName then
			if v:WaitForChild("Type").Value == Type then
				Pets[#Pets + 1] = v.PetID.Value
			end
		end
	end
	if #Pets >= RS.Pets.Settings.PetsRequiredToCraft.Value then
		return Pets
	else
		return nil
	end
end

function GetNextType(TypeName)
	local CurrentValue
	for i,v in pairs(RS.Pets.CraftingTiers:GetChildren()) do
		if v.Name == TypeName then
			CurrentValue = v.Value
		end
	end
	for i,v in pairs(RS.Pets.CraftingTiers:GetChildren()) do
		if v.Value == CurrentValue + 1 then
			return v.Name, CurrentValue + 1
		end
	end
end

function RandomID(Player)
	local Rand = math.random(2,1000000)
	for i,v in pairs(Player.Pets:GetChildren()) do
		if v.PetID.Value == Rand then
			return RandomID()
		end
	end
	return Rand
end

function loadEquipped(Player)
	local CurrentlyEquipped = {}
	for _,Pet in pairs(Player:WaitForChild("Pets"):GetChildren()) do
		if Pet.Equipped.Value == true then
			CurrentlyEquipped[#CurrentlyEquipped + 1] = Pet.PetID.Value
		else
			local ExistentModel = nil
			for _,Part in pairs(workspace.PlayerPets:FindFirstChild(Player.Name):GetChildren()) do
				if Part:FindFirstChild("PetID") then
					if Part.PetID.Value == Pet.PetID.Value then
						ExistentModel = Part
					end
				end
			end
			if ExistentModel ~= nil then
				ExistentModel:Destroy()
			end
		end
	end
	local Increment = 360/#CurrentlyEquipped
	for i,v in pairs(CurrentlyEquipped) do
		local ExistentModel = nil
		local Folder = GetFolderFromPetID(Player, v)
		for _,Part in pairs(workspace.PlayerPets:FindFirstChild(Player.Name):GetChildren()) do
			if Part:FindFirstChild("PetID") then
				if Part.PetID.Value == v then
					ExistentModel = Part
				end
			end
		end
		if ExistentModel ~= nil then
			ExistentModel.Pos.Value = GetPointOnCircle(RS.Pets.Settings.PetCircleRadius.Value, Increment * i)
		else
			local PetModel = RS.Pets.Models:FindFirstChild(Folder.Name):FindFirstChild(Folder.Type.Value):Clone()
			PetModel.Pos.Value = GetPointOnCircle(RS.Pets.Settings.PetCircleRadius.Value, Increment * i)
			PetModel.PetID.Value = v
			PetModel.Parent = workspace.PlayerPets:FindFirstChild(Player.Name)
			PetModel.PrimaryPart:SetNetworkOwner(Player)
		end
	end
end

function ActionRequest(Player, Action, Parameters)
	if Action == "Equip" then
		local Folder = GetFolderFromPetID(Player, Parameters.PetID)
		if Folder ~= nil then
			if Folder.Equipped.Value == false then
				local TotalEquipped = 0
				for i,v in pairs(Player.Pets:GetChildren()) do
					if v.Equipped.Value == true then	
						TotalEquipped = TotalEquipped + 1			
					end
				end
				if TotalEquipped < Player.Data.MaxEquip.Value then
					Folder.Equipped.Value = true
					loadEquipped(Player)
					return "Success"
				else
					return "Error", "Too Many Pets Equipped"
				end
			else
				return "Error", "Pet Already Equipped"
			end
		else
			return "Error", "Invalid Pet"
		end
	elseif Action == "Unequip" then
		local Folder = GetFolderFromPetID(Player, Parameters.PetID)
		if Folder ~= nil then
			if Folder.Equipped.Value == true then
				Folder.Equipped.Value = false
				loadEquipped(Player)
				return "Success"
			else
				return "Error", "Pet Already Unequipped"
			end
		else
			return "Error", "Invalid Pet"
		end
	elseif Action == "Delete" then
		local Folder = GetFolderFromPetID(Player, Parameters.PetID)
		if Folder ~= nil then
			Folder.Equipped.Value = false
			loadEquipped(Player)
			Folder:Destroy()
			return "Success"
		else
			return "Error", "Invalid Pet"
		end
	elseif Action == "Craft" then
		local MainFolder = GetFolderFromPetID(Player, Parameters.PetID)
		local MainType = MainFolder.Type.Value
		local MainName = MainFolder.Name
		if MainFolder ~= nil then
			local Pets = GetAllOfType(Player, MainFolder.Name, MainFolder.Type.Value)
			if Pets ~= nil then
				for i = 1,RS.Pets.Settings.PetsRequiredToCraft.Value do
					local Folder = GetFolderFromPetID(Player, Pets[i])
					Folder.Equipped.Value = false
					loadEquipped(Player)
					Folder:Destroy()
				end
				local Clone = RS.Pets.PetFolderTemplate:Clone()
				local Type, TypeNumber = GetNextType(MainType)
				local Settings = RS.Pets.Models:FindFirstChild(MainName).Settings
				Clone.PetID.Value = RandomID(Player)
				Clone.Multiplier1.Value = Settings.Multiplier1.Value * (RS.Pets.Settings.CraftMultiplier.Value ^ TypeNumber)
				Clone.Multiplier2.Value = Settings.Multiplier2.Value* (RS.Pets.Settings.CraftMultiplier.Value ^ TypeNumber)
				Clone.Type.Value = Type
				Clone.Parent = Player.Pets
				Clone.Name = MainName
				return Clone.PetID.Value
			else
				return "Error", "Not Enough Pets"
			end
		else
			return "Error", "Invalid Pet"
		end
	elseif Action == "Mass Delete" then
		for i,v in pairs(Parameters.Pets) do
			local Folder = GetFolderFromPetID(Player, v)
			if Folder ~= nil then
				Folder.Equipped.Value = false
				loadEquipped(Player)
				Folder:Destroy()
			end
		end
	end
end

RS.RemoteEvents.PetActionRequest.OnServerInvoke = ActionRequest
RS.RemoteEvents.plrWalk.OnServerEvent:Connect(function(Player, State)
	Player.Data:FindFirstChild("isWalking").Value = State
end)

game.Players.PlayerAdded:Connect(function(Player)
	Player.CharacterAppearanceLoaded:Connect(function()
		local Folder = Instance.new("Folder", workspace.PlayerPets)
		Folder.Name = Player.Name
		loadEquipped(Player)
	end)
end)

game.Players.PlayerRemoving:Connect(function(Player)
	local Folder = workspace.PlayerPets:FindFirstChild(Player.Name)
	if Folder then
		Folder:Destroy()
	end
end)

-- Gamepasses

for i,v in pairs(RS.GamepassIDs:GetChildren()) do
	MS.PromptGamePassPurchaseFinished:Connect(function(plr,ido,purchased)
		if purchased and v.Value == ido then
			if v.Name == "TripleOpen" then
				plr.Data.TripleEggOwned.Value = true
			elseif v.Name == "AutoOpen" then
				plr.Data.AutoEggOwned.Value = true
			elseif v.Name == "ExtraEquipped" then
				plr.Data.MaxEquip.Value = RS.Pets.Settings.DefaultMaxEquipped.Value + 5
			elseif v.Name == "ExtraStorage" then
				plr.Data.MaxStorage.Value = RS.Pets.Settings.DefaultMaxStorage.Value + 30
			end
		end
	end)
	game.Players.PlayerAdded:Connect(function(plr)
		local Data = plr:WaitForChild("Data", math.huge)
		if MS:UserOwnsGamePassAsync(plr.UserId, v.Value) then
			if v.Name == "TripleOpen" then
				plr.Data.TripleEggOwned.Value = true
			elseif v.Name == "AutoOpen" then
				plr.Data.AutoEggOwned.Value = true
			elseif v.Name == "ExtraEquipped" then
				plr.Data.MaxEquip.Value = RS.Pets.Settings.DefaultMaxEquipped.Value + 5
			elseif v.Name == "ExtraStorage" then
				plr.Data.MaxStorage.Value = RS.Pets.Settings.DefaultMaxStorage.Value + 30
			end
		end
	end)
end

-- Setup

for _,Folder in pairs(RS.Pets.Models:GetChildren()) do
	for _,Model in pairs(Folder:GetChildren()) do
		if Model.Name ~= "Settings" then
			local PetID = script.PetSetup.PetID:Clone()
			local Pos = script.PetSetup.Pos:Clone()
			local BG = script.PetSetup.BodyGyro:Clone()
			local BP = script.PetSetup.BodyPosition:Clone()
			local FollowScript = script.PetSetup.Follow:Clone()
			local LevelingScript = script.PetSetup.Leveling:Clone()
			PetID.Parent = Model
			Pos.Parent = Model
			BG.Parent = Model.PrimaryPart
			BP.Parent = Model.PrimaryPart
			FollowScript.Parent = Model
			LevelingScript.Parent = Model
		end
	end
end

-- Global Pet Float

local maxFloat = .75
local floatInc = 0.035
local sw = false
local fl = 0

spawn(function() 
	while true do
	    wait()
	    if not sw then
	        fl = fl + floatInc
	        if fl >= maxFloat then
	            sw = true
	        end
	    else
	        fl = fl - floatInc
	        if fl <=-maxFloat then
	            sw = false
	        end
	    end
		script.Parent.globalPetFloat.Value = fl
	end
end)

Here is what I have in my explorer (I don’t know if this is helpful, though):


3. I’ve tried to track down where the error was, but no luck.
All I really need is for the tool to gain leaderstats, which it doesn’t.
I really need an answer on this soon, and if you have any additional questions, please ask.

1 Like

if you click on the error in the output it will show you the specific line that the error is on.

1 Like

Oh yes, the Data problem was on line 189, and the Pet error was on line 24.

1 Like

Can you send a copy of the scripts in a model?
(Please send it in a file rather than a model)

This is so I can edit the scripts easier and direcctly

1 Like

Sure. I will message you after.