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

why won't this work??? it says it needs a end at line 35 near do

Asked by 5 years ago

It's a sprint script with a stamina bar but there all broke atm

local Bar = script.Parent:WaitForChild('STMBackground'):WaitForChild('Bar')
local power = 10
local Player = game.Players.LocalPlayer
    local Character = workspace:WaitForChild(Player.Name)
        local Humanoid = Character:WaitForChild('Humanoid')

local RunAnimation = Instance.new('Animation')
RunAnimation.AnimationId = 'rbxassetid://4518254126'
RAnimation = Humanoid:LoadAnimation(RunAnimation)

Running = false

function Handler(BindName, InputState)
    if InputState == Enum.UserInputState.Begin and BindName == 'RunBind' then
        Running = true
        Humanoid.WalkSpeed = 37
        Humanoid.JumpPower = 70
        power = power - .03
    elseif InputState == Enum.UserInputState.End and BindName == 'RunBind' then
        Running = false
        if RAnimation.IsPlaying then
            RAnimation:Stop()
        end
        Humanoid.WalkSpeed = 7
        Humanoid.JumpPower = 50
    end
end

Humanoid.Running:connect(function(Speed)
    if Speed >= 10 and Running and not RAnimation.IsPlaying then
        RAnimation:Play()
        Humanoid.WalkSpeed = 37
        Humanoid.JumpPower = 70
        while power > 0 and Running do
            power = power - .03
        Bar.Size = UDim2.new(power / 10, 0, 1, 0)
        wait()
        if power <= 0 then
                Character.Humanoid.WalkSpeed = 70
        elseif Speed >= 10 and not Running and RAnimation.IsPlaying then
        while power < 10 and not Running do
        RAnimation:Stop()
        Humanoid.WalkSpeed = 7
        Humanoid.JumpPower = 50
        power = power + .03
            Bar.Size = UDim2.new(power / 10, 0, 1, 0)
                wait()
            if power <= 0 then
                Character.Humanoid.WalkSpeed = 7
    elseif Speed < 10 and RAnimation.IsPlaying then
        RAnimation:Stop()
        Humanoid.WalkSpeed = 7
        Humanoid.JumpPower = 70
                end
             end
          end

Humanoid.Changed:connect(function()
    if Humanoid.Jump and RAnimation.IsPlaying then
        RAnimation:Stop()
    end
end)

game:GetService('ContextActionService'):BindAction('RunBind', Handler, true, Enum.KeyCode.LeftShift)

2 answers

Log in to vote
1
Answered by
bluzorro 417 Moderation Voter
5 years ago
Edited 5 years ago

You forgot to add the end for the while loop. I suppose this should be your correct code:

local Bar = script.Parent:WaitForChild('STMBackground'):WaitForChild('Bar')
local power = 10
local Player = game.Players.LocalPlayer
    local Character = workspace:WaitForChild(Player.Name)
        local Humanoid = Character:WaitForChild('Humanoid')

local RunAnimation = Instance.new('Animation')
RunAnimation.AnimationId = 'rbxassetid://4518254126'
RAnimation = Humanoid:LoadAnimation(RunAnimation)

Running = false

function Handler(BindName, InputState)
    if InputState == Enum.UserInputState.Begin and BindName == 'RunBind' then
        Running = true
        Humanoid.WalkSpeed = 37
        Humanoid.JumpPower = 70
        power = power - .03
    elseif InputState == Enum.UserInputState.End and BindName == 'RunBind' then
        Running = false
        if RAnimation.IsPlaying then
            RAnimation:Stop()
        end
        Humanoid.WalkSpeed = 7
        Humanoid.JumpPower = 50
    end
end

Humanoid.Running:connect(function(Speed)
    if Speed >= 10 and Running and not RAnimation.IsPlaying then
        RAnimation:Play()
        Humanoid.WalkSpeed = 37
        Humanoid.JumpPower = 70
        while power > 0 and Running do
            power = power - .03
        Bar.Size = UDim2.new(power / 10, 0, 1, 0)
        wait()
    end -- this is the end that gave you the error.
        if power <= 0 then
                Character.Humanoid.WalkSpeed = 70
        elseif Speed >= 10 and not Running and RAnimation.IsPlaying then
        while power < 10 and not Running do
        RAnimation:Stop()
        Humanoid.WalkSpeed = 7
        Humanoid.JumpPower = 50
        power = power + .03
            Bar.Size = UDim2.new(power / 10, 0, 1, 0)
                wait()
            if power <= 0 then
                Character.Humanoid.WalkSpeed = 7
    elseif Speed < 10 and RAnimation.IsPlaying then
        RAnimation:Stop()
        Humanoid.WalkSpeed = 7
        Humanoid.JumpPower = 70
                end
             end
          end

Humanoid.Changed:connect(function()
    if Humanoid.Jump and RAnimation.IsPlaying then
        RAnimation:Stop()
    end
end)

game:GetService('ContextActionService'):BindAction('RunBind', Handler, true, Enum.KeyCode.LeftShift)
0
thanks! Deinonychusaurus 21 — 5y
Ad
Log in to vote
0
Answered by 5 years ago

i think you forgot to add 1 end for the line

        while power > 0 and Running do -- line 34, needs an end
                power = power - .03 --line 35

Answer this question