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

My jump detector doesn't add points to the leader board?

Its supposed to add 1 point to the leader board every time you jump. The problem is in the title.

local JumpValue = game.Players.LocalPlayer.leaderstats.Currency.Value
local player = game.Players.LocalPlayer
local Char = player.Character
local Humanoid = Char.Humanoid

Humanoid:GetPropertyChangedSignal("Jump"):Connect(function()
    JumpValue = JumpValue + 1
end)

2 answers

local JumpValue = game.Players.LocalPlayer.leaderstats.Currency
local player = game.Players.LocalPlayer
local Char = player.Character
local Humanoid = Char.Humanoid

Humanoid.Jumping:Connect(function()
    JumpValue.Value = JumpValue.Value + 1
end)

3 comments

0

also DO NOT ADD THE VALUES ON CLIENT otherwise it could go wrong

0

Didn't seem to work.

0

yeah because local player cannot be accessed on server

This should work. Make sure it's a regular script/ServerScript inside ServerScriptService.

game:GetService("Players").PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		character.Humanoid.Jumping:Connect(function()
			player.leaderstats.Currency.Value = player.leaderstats.Currency.Value + 1
		end)
	end)
end)

The PlayerAdded event fires when a player is added to the game, the CharacterAdded event fires when the player's character is added, and the Jumped event fires when the player jumps.

20 comments

0

It says leaderstats is not a valid member of players.

0

Then you must've typed something incorrectly. Try copy and pasting.

0

Then either leaderstats ins't in the player or value called Currency inside leaderstats doesn't exist.

0

The leaderstats is in the player in the players tab.

0

Try using :WaitForChild() on the leaderstats. I edited the normal/server script code.

0

Tell me if it says anything about infinite yield.

0

Infinite yield possible in some random chat thing in replicated storage, nothing happens and no logs

0

Then I am afraid I do not know what is wrong with your code. Sorry about that.

0

frick.

0

Actually, I might know a way to fix it. I'm gonna edit my post hold on..

0

Its starting to work but I don't think it registers some jumps and it is not giving the user currency sometimes.

0

Try it now. I've edited it.

0

Doesn't work now.

0

I edited again. It should work.

0

Still doesn't seem to.

0

I made yet another mistake. Please try again. I've edited it.

0

Mmm, still doenst seem to be registering on some jumps, mostly elimanted now but it has a weird thing where its doubling

0

Oh. Then yet again. I can't help you.

0

Well thank you anyways for doing this.

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