So I have a script inside a model named "Brick" and the brick has a humanoid. Basically once you kill the brick, you will get points. However once I kill the brick, I'm not receiving any points. Any help?

local Humanoid = script.Parent.Humanoid
function Died()
	local p = Humanoid:findFirstChild("creator")
	if p ~= nil then
		if p.Value ~= nil then
			local Leaderstats = p.Value:findFirstChild("leaderstats")
			if Leaderstats ~= nil then
				Leaderstats.Points.Value = Leaderstats.Points.Value + 5

wait(0.1)

script:remove()

end

end

end

end

Humanoid.Died:connect(Died)

2 comments

0

Please try actually indenting the code. Also, try to give your functions appropiate names, as when someone sees "YahYeet" They're not going to have a clue of what it's supposed to do.

1

The script you did doesn't work because it is looking for the leaderstats inside of the thing you want to kill, instead, you should search for the leaderstats inside of the character that killed it. Hope this helps.