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

My Local Script only works in studio. It dose not work in studio for some reason? Please help me fix

Asked by 5 years ago
Edited 5 years ago

Basicaly I want this to count the number of times you jump. If you reached a certain amount of jumps I want it to do something. For some reason It only works on studio. Here is the code:

local plr = game.Players.LocalPlayer.Character
local debounce = false
local debounce2 = false
local Jumps = game.Players.LocalPlayer.leaderstats
local JumpCounter = script.Parent.Parent.Jumps
local Sound = script.Parent.Parent.Sound
plr.Humanoid.Changed:connect(function(prop)
    if prop == 'Jump' and not debounce then
        debounce = not debounce
game.Players.LocalPlayer.leaderstats.Jumps.Value = game.Players.LocalPlayer.leaderstats.Jumps.Value + 1
JumpCounter.Text = game.Players.LocalPlayer.leaderstats.Jumps.Value
if(game.Players.LocalPlayer.leaderstats.Jumps.Value >= 50) then
    Sound:Play() 
    wait(3)
    Sound:Destroy()
    script.Parent.Parent.Trail1.Visible = true
else
    script.Parent.Parent.Trail1.Visible = false
end

        wait()
        debounce = not debounce
    end
end)


0
Filtering Enabled is Enabled or Disabled? oftenz 367 — 5y
0
It is always enabled... thesit123 509 — 5y

1 answer

Log in to vote
0
Answered by
thesit123 509 Moderation Voter
5 years ago
Edited 5 years ago

You should be using Jumping() event.

local plr = game.Players.LocalPlayer.Character
local debounce = false
local debounce2 = false
local Jumps = game.Players.LocalPlayer.leaderstats
local JumpCounter = script.Parent.Parent.Jumps
local Sound = script.Parent.Parent.Sound

plr.Humand.Jumping:Connect(function()
    if not debouce then
        debounce = true
        Jumps .Jumps.Value = Jumps .Jumps.Value + 1
        JumpCounter = Jumps .Jumps.Value

        if(game.Players.LocalPlayer.leaderstats.Jumps.Value >= 50) then
            Sound:Play()
            wait(3)
            Sound:Destroy()
            script.Parent.Parent.Trail1.Visible = true
        else
            script.Parent.Parent.Trail1.Visible = false
        end
        debounce = not debounce
    end
end)
0
Im geting a error for line 8 that the humanoid is not a valid member of model. appleprogamer_59 29 — 5y
0
Nvm fixed it! appleprogamer_59 29 — 5y
0
Glad I help, sorry for that typo there thesit123 509 — 5y
Ad

Answer this question