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

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

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)


2 comments

0

Filtering Enabled is Enabled or Disabled?

0

It is always enabled...

1 answer

✓ Accepted answer

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)

3 comments

0

Im geting a error for line 8 that the humanoid is not a valid member of model.

0

Nvm fixed it!

0

Glad I help, sorry for that typo there

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