Probably another simple fix

Ah yes yet another discussion about swords. I have a sword script and inside is a function where if something is killed +1 souls is added to the leader boards. Though there are different types of mobs in my game that I want to give a different amount of souls on death. For example a chicken gives 2 souls while a frog gives 4. I already tried this with my script though it didn’t work.

local tool = script.Parent
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")

local function OnTouch(partOther)
	if db1 then
		if dbAnim then

			local character = partOther.Parent

			local humanOther = character:FindFirstChild("Humanoid")

			if not humanOther then return end

			if humanOther.Parent == tool then return end

			local player = Players:GetPlayerFromCharacter(character)
			if player and (player == Player or IsTeamMate(Player, player)) then
				return
			end

			UntagHumanoid(humanOther)
			TagHumanoid(humanOther, Player)

			humanOther:TakeDamage(damage)

			db1 = false
		end
	end
end

local InputService = game:GetService("UserInputService")
local InputType = Enum.UserInputType

local animation = nil
local slashAnimation = nil

tool.Equipped:Connect(function()
	animation = Instance.new("Animation")
	animation.AnimationId = "rbxassetid://7132227504"
	slashAnimation = humanoid:LoadAnimation(animation)
end)

tool.Unequipped:Connect(function()
	animation:Destroy()
	slashAnimation = nil
end)

local debounce = false
InputService.InputBegan:Connect(function(input, processed)
	if input.UserInputType == InputType.MouseButton1 and slashAnimation and not processed then
		if debounce == false then
			debounce = true

			slashAnimation:Play()
			local Connection
			local tool = script.Parent

			local function onTouch(partOther)     --The function that gives souls

				local humanOther = partOther.Parent:FindFirstChild("Humanoid")

				if not humanOther then return end

				if humanOther.Parent == tool then return end

				humanOther:TakeDamage(5) 
				if game.humanOther.Health <= 0 then
					player.leaderstats.Souls.Value =  player.leaderstats.Souls.Value + 1
					humanOther.Parent:Destroy()
				end
			end

			Connection = tool.Handle.Touched:Connect(onTouch)

			slashAnimation.Stopped:Wait() 
			debounce = false
			Connection:Disconnect()
			wait(.2)
			debounce = false

		end

	end
end)	

You can do this using if statements (for example check whatever model has a name “Frog” or “Chicken”) or add an IntValue to the model named “SoulsPerKill” or something like that and store in there the value of souls to give when killed.

ya I did that though it didn’t work.

			local function onTouch(partOther)

				local humanOther = partOther.Parent:FindFirstChild("Humanoid")

				if not humanOther then return end

				if humanOther.Parent == tool then return end

				humanOther:TakeDamage(5)
				if game.Frog.Health <= 0 then
					player.leaderstats.Souls.Value =  player.leaderstats.Souls.Value + 1
					humanOther.Parent:Destroy()
				if game.Chicken.Health <= 0 then
						player.leaderstats.Souls.Value =  player.leaderstats.Souls.Value + 1
						humanOther.Parent:Destroy()
					
					
					end
				end
			end

			Connection = tool.Handle.Touched:Connect(onTouch)

You store the models directly inside the game object?

The objects are in replicated storage

Then why it is game.Frog instead of game.ReplicatedStorage.Frog?

Oh ye didn’t think of that… I’ll try that rn.

This is weird now only the chickens are giving the proper amount of souls not frogs.

				humanOther:TakeDamage(5)
				if game.ReplicatedStorage.Frog.Health <= 0 then
					player.leaderstats.Souls.Value =  player.leaderstats.Souls.Value + 4
					humanOther.Parent:Destroy()
				if game.ReplicatedStorage.Chicken.Health <= 0 then
						player.leaderstats.Souls.Value =  player.leaderstats.Souls.Value + 2
						humanOther.Parent:Destroy()

Actually I want to try something real quick…

I don’t know if you’ve finished testing your quick attempt, but I’d like to ask a few questions.

What method do you use so your script can distinguish your frogs from your chickens?
I’d imagine you’re using their name, seen by the fact that you’re referencing them by name in ReplicatedStorage, but I want to be sure.