Leaderstats Value adding by each person joining

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 made a leaderstats folder in the player with an IntValue called “Noots” to find out how many times a player has pressed the letter N (Or a button on the screen in case of a mobile player)

  2. What is the issue? Include screenshots / videos if possible!
    When two or more players join, the Noots value adds one more point by each player in the server ( I don’t know if I phrased this correctly, you can just see the video I put below to make up the issue)

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I have tried some solutions, but not from the Developer Hub, it was me who did them, and this one is the only one that works, but is still broken

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 player = game.Players.LocalPlayer

local debounce = false

local uis = game:GetService("UserInputService")

uis.InputBegan:Connect(function(input, soundglobal)
	if input.KeyCode == Enum.KeyCode.N then
		if debounce == false then
			debounce = true
			local sound = script.noot
			local newsound = sound:Clone()
			newsound.Parent = player.Character:FindFirstChild("HumanoidRootPart")
			soundglobal = sound
			game.ReplicatedStorage.SendNoot:FireServer(sound)
			local hum = player.Character:WaitForChild("Humanoid")
			local anim = hum:LoadAnimation(script:FindFirstChildOfClass("Animation"))
			anim.Looped = false
			anim:Play()
			print("noot")
			wait(.3)
			debounce = false
		end
	end
end)

player.PlayerGui.ControlMenu.NootMobile.InputBegan:Connect(function(soundglobal)
	if debounce == false then
		debounce = true
		local sound = script.noot
		local newsound = sound:Clone()
		newsound.Parent = player.Character:FindFirstChild("HumanoidRootPart")
		soundglobal = sound
		game.ReplicatedStorage.SendNoot:FireServer(sound)
		local hum = player.Character:WaitForChild("Humanoid")
		local anim = hum:LoadAnimation(script:FindFirstChildOfClass("Animation"))
		anim.Looped = false
		anim:Play()
		print("noot")
		wait(.3)
		debounce = false
	end
end)

The script above the text is the Local Script, put in StarterCharacterScripts

 game.ReplicatedStorage.SendNoot.OnServerEvent:Connect(function(player)
	local sound = script.noot:Clone()
	sound.PitchShiftSoundEffect.Octave = math.random(1,1.5)
	sound.Parent = player.Character.HumanoidRootPart
	player.leaderstats.Noots.Value +=1
	sound:Play()
end)

The script above the text is the Server Script, also put in StarterCharacterScripts


(Clip proving that in single player this doesn’t happen)

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.

You placed a Server Script under StarterCharacterScripts.

Never do that.
Never place any server script under StarterPlayerScripts, StarterCharacterScripts, or any place that’s supposed to be for LocalScripts.

You have multiple instances of the same code per character, meaning those scripts are connected to the same event.

Move that server script under ServerScriptService.

1 Like

Thanks! I’ll be more careful to where to place Local and Server scripts

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.