Adding score system to my code

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!

I have created two working codes, first one adds points when you touch the button and the other one senses when a specific brick is in contact and starts the code

  1. What is the issue? Include screenshots / videos if possible!

issue is i cant get them to work together and i need to combine them

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

ive looks on many developer hubs and tried different things but nothing seems to work

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

local delay = false

script.Parent.Touched:Connect(function(hit)
	local player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
	
	if player then
		if delay == false then
			player.leaderstats.Bananas.Value += script.Parent.Value.Value
			
			delay = true
			wait(1.1)
			delay = false
		end
	end
end)
Touch = script.Parent
Running = script.Parent.Playing.Value
Eye1 = script.Parent.Parent.Eye1
Eye2 = script.Parent.Parent.Eye2
Animation1 = script.Parent.Parent.Secondarybody
Animation2 = script.Parent.Parent.Secondarybody2

Sparks = script.Parent.Parent.Glow

-------------------------------------------------------------------------

Touch.Touched:Connect(function(other)
	if other.Name == "spills" then
		if Running == false then
			Running = true
			
			-------------------------------------------------------------
			
			script.Parent.Parent.Cry.Cry.Playing = false
			script.Parent.Parent.Mouth.Transparency = 1
			script.Parent.Parent.Banana.Transparency = 0
			
			Eye1.Transparency = 0
			Eye1.Decal.Transparency = 0
			Eye2.Transparency = 0
			Eye2.Decal.Transparency = 0
			
			Animation1.Transparency = 1
			Animation2.Transparency = 0
			
			script.Parent.Parent.Tears.ParticleEmitter.Enabled = false
			script.Parent.Parent.Tears2.ParticleEmitter.Enabled = false
			
			Sparks.Sparkles.Enabled = true
			wait(1)
			Sparks.Sparkles.Enabled = false
			
			-------------------------------------------------------------
			wait(9)
			-------------------------------------------------------------
			script.Parent.Parent.Cry.Cry.Playing = true
			script.Parent.Parent.Mouth.Transparency = 0
			script.Parent.Parent.Banana.Transparency = 1
			
			Eye1.Transparency = 1
			Eye1.Decal.Transparency = 1
			Eye2.Transparency = 1
			Eye2.Decal.Transparency = 1
			
			Animation1.Transparency = 0
			Animation2.Transparency = 1
			
			script.Parent.Parent.Tears.ParticleEmitter.Enabled = true
			script.Parent.Parent.Tears2.ParticleEmitter.Enabled = true
			-------------------------------------------------------------
			Running = false
		end
	end
end)

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

I tried putting a local function inside the second script with the lines “player.leaderstats.Bananas.Value += script.Parent.Value.Value” inside of it but it didnt seem to work im not the best with coding and unsure what to do

The main goal really is to get +1 score added onto the leaderstats “Banana” once when the block “spills” is detected

Why can’t you do value += 1 then?

Yea thats basically what script.Parent.Value.Value does except i used a value so i can change it easier than having to go into the code.

I want to be able to do something like this in the second code so that the “spills” triggers it rather than sensing for the humanoid touched