Trying to give cash for the player when makes kills

the only reason i told you to add an object value is so you can reference the player in the bullet script

local bullet = script.Parent
local HitSound = script.Parent.HitShotSound
local plr = bullet.creator.Value --this is what i meant
local leaderstats = plr:WaitForChild("toolLeaderstats")
local credits = leaderstats:WaitForChild("Credits")

local function player_check(otherPart)
	local humanoid = otherPart.Parent:FindFirstChild("Humanoid")
	if humanoid and humanoid.Parent.Name ~= bullet.Attacker.Value then
		if otherPart.Name == "Head" then
			humanoid:TakeDamage(100)
			HitSound:Play()
			if humanoid.Health >= 0 then
				credits.Value = credits.Value + 10
				bullet:Destroy()
			else
				humanoid:TakeDamage(50)
				HitSound:Play()
				if humanoid.Health >= 0 then
					credits.Value = credits.Value + 10
					bullet:Destroy()
				end
			end
		end
	end
end


bullet.Touched:Connect(player_check)
game.Debris:AddItem(bullet, 10)

ok I will show you the give cash script.

local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		local humanoid = character:WaitForChild("Humanoid")

		humanoid.Died:Connect(function()
			if humanoid:FindFirstChild("creator") then
				local FindPlayer = humanoid:FindFirstChild("creator").Value
				FindPlayer.toolLeaderstats.Cash.Value += 10 
			end
		end)
	end)
end)

when the script found inside any humanoid one value named “creator” this will give money to the player (imagine the creator value is “ToxicalGamer2006” I will get 10 cash)

you could clone the “tag” value and parent it to the enemy humanoid
try this script next

local bullet = script.Parent
local HitSound = script.Parent.HitShotSound
local plr = bullet.creator.Value --this is what i meant
local leaderstats = plr:WaitForChild("toolLeaderstats")
local credits = leaderstats:WaitForChild("Credits")

local function player_check(otherPart)
	local humanoid = otherPart.Parent:FindFirstChild("Humanoid")
	if humanoid and humanoid.Parent.Name ~= bullet.Attacker.Value then
        local creator = bullet.creator:Clone()
        creator.Parent = humanoid
		if otherPart.Name == "Head" then
			humanoid:TakeDamage(100)
			HitSound:Play()
			if humanoid.Health >= 0 then
				credits.Value = credits.Value + 10
				bullet:Destroy()
			else
				humanoid:TakeDamage(50)
				HitSound:Play()
				if humanoid.Health >= 0 then
					credits.Value = credits.Value + 10
					bullet:Destroy()
				end
			end
		end
	end
end


bullet.Touched:Connect(player_check)
game.Debris:AddItem(bullet, 10)
1 Like

I am getting one error about the value on SSS script.

can you post the error here so i can fix it?

ServerScriptService.ToolsDamageSettings.MLGsniperBulletSettings:25: invalid argument #3 (string expected, got Instance)

I have to change the parent or something?

weird, it should be fine, is the tag an object value?

no is one StringValue. I will try to change for use one ObjectValue

Ok I fixed I changed with one ObjectValue now I got other problem.

creator is not a valid member of UnionOperation "Workspace.Bullet"

local bullet = script.Parent
local HitSound = script.Parent.HitShotSound
local plr = bullet.creator

local function player_check(otherPart)
	local humanoid = otherPart.Parent:FindFirstChild("Humanoid")
	if humanoid and humanoid.Parent.Name ~= bullet.Attacker.Value then
        local creator = bullet.creator:Clone()
        creator.Parent = humanoid
		if otherPart.Name == "Head" then
			humanoid:TakeDamage(100)
			HitSound:Play()
			if humanoid.Health >= 0 then
				credits.Value = credits.Value + 10
				bullet:Destroy()
			else
				humanoid:TakeDamage(50)
				HitSound:Play()
				if humanoid.Health >= 0 then
					credits.Value = credits.Value + 10
					bullet:Destroy()
				end
			end
		end
	end
end


bullet.Touched:Connect(player_check)
game.Debris:AddItem(bullet, 10)

this is the fixed way^^ :grinning_face_with_smiling_eyes:

Doest it work? If it does you can mark it as the solution