Help with Fixing My Code

first event is the one you need to remove and secondl one

okay


player.CharacterAdded:connect(function(character)

character:WaitForChild("Humanoid").Died:connect(function()
	
	local tag = character.Humanoid:FindFirstChild("creator")
	
	if tag ~= nil then
		
		if tag.Value ~= nil then
			
			local stats = tag.Value:WaitForChild("leaderstats")
			
			stats["Gold"].Value = stats ["Gold"].Value + 150
			
			
			
			
		end
		
	end
	
end)

end)

It should start with character:WaitForChild(“Humanoid”) one

So I remove ```game.Players.PlayerAdded:connect(function(player)

did you the character variable

the problem with taht is the first two lines define it

I cant remove the first two lines because it would create an error I think

you didnt remove the end)s too

it should begin with humanoid died event

let me make sure I got this right


		
		character:WaitForChild("Humanoid").Died:connect(function()
			
			local tag = character.Humanoid:FindFirstChild("creator")
			
			if tag ~= nil then
				
				if tag.Value ~= nil then
					
					local stats = tag.Value:WaitForChild("leaderstats")
					
					stats["Gold"].Value = stats ["Gold"].Value + 150
					
					
					
					
				end
				
			end
			
		end)
		
	end)

The end) is still there so it will error only one end)

like that?

	
	player.CharacterAdded:connect(function(character)
		
		character:WaitForChild("Humanoid").Died:connect(function()
			
			local tag = character.Humanoid:FindFirstChild("creator")
			
			if tag ~= nil then
				
				if tag.Value ~= nil then
					
					local stats = tag.Value:WaitForChild("leaderstats")
					
					stats["Gold"].Value = stats ["Gold"].Value + 150

you were supposed to remove the end) not the end too

Sorry it is hard to type on mobile


		character:WaitForChild("Humanoid").Died:connect(function()
			
			local tag = character.Humanoid:FindFirstChild("creator")
			
			if tag ~= nil then
				
				if tag.Value ~= nil then
					
					local stats = tag.Value:WaitForChild("leaderstats")
					
					stats["Gold"].Value = stats ["Gold"].Value + 150
					
					
					
					
				end
				
			end
			
		end)
1 Like

That is right i think but makesure you put the character variable down

which is local character = script.Parent

on the first line? Thanks So Much!

yes so character wont be nil and wont error

So My DataStore2 Script goes to ServerScriptService and my Killing script goes to StarterPlayerScript?