Would this work? money for murder script

game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(char)
local humanoid = char:WaitForChild(“Humanoid”)
local Alive = true

–// Player Died function
humanoid.Died:Connect(function()
if Alive == true then
Alive = false
wait(0.25)

	local killed = humanoid:FindFirstChild("creator")


	if killed then
		if player ~= killed.Value then
					killed.Value.leaderstats.Kills.Value = killed.Value.leaderstats.Kills.Value + 1
					killed.Value.leaderstats.Cash.Value = killed.Value.leaderstats.Cash.Value + 700
		end
	end
end
end)	
end)
end)

It is a server script that is supposed to know which player killed another player and add the leaderstats but I haven’t tried it and I don’t know if it works, could you tell me if yes?

The script you provided should work.
However, there is one small issue with the script: the line that sets Alive to false should be moved to after the if killed then block.
I corrected it for you, this one should be functional:

game.Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(char)
        local humanoid = char:WaitForChild("Humanoid")
        local Alive = true

        -- Player Died function
        humanoid.Died:Connect(function()
            if Alive == true then
                wait(0.25)
                local killed = humanoid:FindFirstChild("creator")
                if killed then
                    if player ~= killed.Value then
                        killed.Value.leaderstats.Kills.Value = killed.Value.leaderstats.Kills.Value + 1
                        killed.Value.leaderstats.Cash.Value = killed.Value.leaderstats.Cash.Value + 700
                    end
                end
                Alive = false
            end
        end)    
    end)
end)

Other than that, the script looks good and should work as intended!

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.