Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

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

Asked by 4 years ago

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

Log in to vote
0
Answered by 4 years ago
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)
0
also DO NOT ADD THE VALUES ON CLIENT otherwise it could go wrong WerewolfCanPoition88 59 — 4y
0
Didn't seem to work. Kilonove 7 — 4y
0
yeah because local player cannot be accessed on server WerewolfCanPoition88 59 — 4y
Ad
Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

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.

0
It says leaderstats is not a valid member of players. Kilonove 7 — 4y
0
Then you must've typed something incorrectly. Try copy and pasting. youtubemasterWOW 2741 — 4y
0
Then either leaderstats ins't in the player or value called Currency inside leaderstats doesn't exist. youtubemasterWOW 2741 — 4y
View all comments (16 more)
0
The leaderstats is in the player in the players tab. Kilonove 7 — 4y
0
Try using :WaitForChild() on the leaderstats. I edited the normal/server script code. youtubemasterWOW 2741 — 4y
0
Tell me if it says anything about infinite yield. youtubemasterWOW 2741 — 4y
0
Infinite yield possible in some random chat thing in replicated storage, nothing happens and no logs Kilonove 7 — 4y
0
Then I am afraid I do not know what is wrong with your code. Sorry about that. youtubemasterWOW 2741 — 4y
0
frick. Kilonove 7 — 4y
0
Actually, I might know a way to fix it. I'm gonna edit my post hold on.. youtubemasterWOW 2741 — 4y
0
Its starting to work but I don't think it registers some jumps and it is not giving the user currency sometimes. Kilonove 7 — 4y
0
Try it now. I've edited it. youtubemasterWOW 2741 — 4y
0
Doesn't work now. Kilonove 7 — 4y
0
I edited again. It should work. youtubemasterWOW 2741 — 4y
0
Still doesn't seem to. Kilonove 7 — 4y
0
I made yet another mistake. Please try again. I've edited it. youtubemasterWOW 2741 — 4y
0
Mmm, still doenst seem to be registering on some jumps, mostly elimanted now but it has a weird thing where its doubling Kilonove 7 — 4y
0
Oh. Then yet again. I can't help you. youtubemasterWOW 2741 — 4y
0
Well thank you anyways for doing this. Kilonove 7 — 4y

Answer this question