Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

My script gives me an error message whenever I end the script?

I literally cannot end this script, it's always a red line under the end or an error message! How the hell do I end this script?

game.Players.PlayerAdded:Connect(function(player)

    player.CharacterAdded:Connect(function(character)

        if game.MarketplaceService:PlayerOwnsAsset(player,7187215) then

            game.Players.PlayerAdded:connect(function(p) p.CharacterAdded:connect(function(c)

c.Humanoid.Died:connect(function() local cv = c.Humanoid:findFirstChild("creator") if cv

then local k = cv.Value if k and k ~= p then k.leaderstats.Money.Value =

k.leaderstats.Money.Value+4


else

     game.Players.PlayerAdded:connect(function(p) p.CharacterAdded:connect(function(c)

c.Humanoid.Died:connect(function() local cv = c.Humanoid:findFirstChild("creator") if cv

then local k = cv.Value if k and k ~= p then k.leaderstats.Money.Value =

k.leaderstats.Money.Value+4

end end end) end) end)


 end
end)

   








Thanks!

1 answer

Well, you needed some more "ends" and closed ends for the functions.... I think there's a ton of redundancy here and maybe this code should be reorganized a bit.. You're setting up character added events 3 times.... all nested within a player added event... This will at least get your script running without an error, but not sure if it works, otherwise... Notice my comments to help figure out the puzzle of what was wrong.. and the formatting...

game.Players.PlayerAdded:Connect(function(player)

    player.CharacterAdded:Connect(function(character)

        if game.MarketplaceService:PlayerOwnsAsset(player,7187215) then

        	game.Players.PlayerAdded:connect(function(p) 
			p.CharacterAdded:connect(function(c)

			c.Humanoid.Died:connect(function() 
	


				local cv = c.Humanoid:findFirstChild("creator") 
				
				if cv
				
				then 
						
									local k = cv.Value 
									
									
									if k and k ~= p then 
										
										endk.leaderstats.Money.Value = k.leaderstats.Money.Value+4
									
									
									else
								
													     	game.Players.PlayerAdded:connect(function(p) 
														
																	p.CharacterAdded:connect(function(c)
													
																	c.Humanoid.Died:connect(function() 
																		
																			local cv = c.Humanoid:findFirstChild("creator") 
																			if cv
															
																			then 
																				
																					local k = cv.Value 
																					if k and k ~= p then 
																						
																						endk.leaderstats.Money.Value = k.leaderstats.Money.Value+4
															
																					end  -- end k and k ~= p
																			end -- end if cv
															
																	end) -- c.Humanoid.Died:connect
																	end) -- p.CharacterAdded:connect
																	end) -- game.Players.PlayerAdded:connect(function(p)
								
									end -- end if k and k ~= p then 
				end -- end if cv
				
		end) -- end the died:connect (again???)
		end) -- p.CharacterAdded:connect(function(c) (again???)
		end) --  game.Players.PlayerAdded:connect (again)???

end --   if game.MarketplaceService:PlayerOwnsAsset(player,7187215) 





end) --  player.CharacterAdded:Connect(function(character)
end) -- game.Players.PlayerAdded:Connect(function(player)

1 comment

0

a lot of the code is out of view.. sorry, you'll need to use the "Copy" button to see it all.

This discussion is preserved as it was. New answers, comments, and votes are closed.