Why when it is meant to change clicks, is it changing rebirths

hey there,
I’m making a clicker simulator game and I wanted the player to be able to rebirth, but when the player clicks to add to the clicks, it changes the rebirths

clicks script

local add = 1

script.Parent.Parent.ImageButton.MouseButton1Click:Connect(function()
	game.ReplicatedStorage.PlayerClicked:FireServer(add)
end)

Clicks Event script:

game.ReplicatedStorage.PlayerClicked.OnServerEvent:Connect(function(player, add)
	player.leaderstats.Clicks.Value = player.leaderstats.Clicks.Value + add
end)

rebirth script:

local Rebirths = 1

script.Parent.MouseButton1Click:Connect(function(player)
	if game.Players.LocalPlayer.leaderstats.Clicks.Value >= Rebirths * 1000 then
		game.ReplicatedStorage.Rebirth:FireServer(Rebirths)
	end
end)

rebirth event script:

game.ReplicatedStorage.PlayerClicked.OnServerEvent:Connect(function(player, Rebirths)
	player.leaderstats.Clicks.Value = 0
	player.leaderstats.Rebirths.Value = player.leaderstats.Rebirths.Value + Rebirths
end)

This is happeing because You bound Rebirth logic to game.ReplicatedStorage.PlayerClicked.OnServerEvent which is firing when player wants to add points. Bind Rebirth logic to game.ReplicatedStorage.Rebirth.OnServerEvent and it will work fine

The event should be named Rebirth instead PlayerClicked:

game.ReplicatedStorage.Rebirth.OnServerEvent:Connect(function(player, Rebirths)
    player.leaderstats.Clicks.Value = 0
	player.leaderstats.Rebirths.Value = player.leaderstats.Rebirths.Value + Rebirths
end)

You are using the wrong event to add the rebirth in the fourth script. Also, your method of adding clicks is exploitable. An exploiter will be able to change the “add” value in the first script to something big and will gain a lot instead of 1. Same to the “rebirths” value in the third script.

change your local rebirths script to

local Rebirths = 1

script.Parent.MouseButton1Click:Connect(function(player)
	if game.Players.LocalPlayer.leaderstats.Clicks.Value >= Rebirths * 1000 then
		game.ReplicatedStorage.Rebirth:FireServer(nil, Rebirths) --so it doesn't send rebirths as clicks
	end
end)

and chance the server rebirth script to

game.ReplicatedStorage.PlayerClicked.OnServerEvent:Connect(function(player, nil, Rebirths) -- again, so it doesn't change the rebirths value to clicks
	player.leaderstats.Clicks.Value = 0
	player.leaderstats.Rebirths.Value = player.leaderstats.Rebirths.Value + Rebirths
end)