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

[UPDATE!] The output says that i need to close my function on line 32... ????????

Asked by
xVanc -1
7 years ago
Edited 7 years ago

I'm sorry for the inconvenience, I have released I had many spelling errors, and other errors. I've fixed those mistakes, though there is still a problem. It says that I need to close my function on line 32... I did..? Btw, I changed the localscript below.

game:GetService("StarterGui"):SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)

local players = game:GetService("Players")
local inputService = game:GetService("UserInputService")

local player = players.LocalPlayer 
local character = playerCharacter or player.CharacterAdded:wait()
local humanoid = character:WaitForChild("Humanoid")

local stamina = 100

local Interface = {}
do
    local playerGui = player:WaitForChild("PlayerGui")

    local gui = playerGui:WaitForChild("Stamina")
    local frame = gui:WaitForChild("Frame")
    local textlabel = frame:WaitForChild("TextLabel")
    local bar = frame:WaitForChild("Percentage")

    local UDim2_new = UDim2.new

    function Interface:UpdateStamina()
        bar.Size = UDim2_new(stamina/100, 0, 0, 0)
        textLabel.Text = ("Stamina - 4d / 100")format(stamina)
    end


end


inputService.InputBegan:connect(function(input, event)
    if (event or stamina <= 0) then return end

    local key = input.KeyCode.Name
    print(key)

    if (key == "LeftControl") then
        humanoid.Walkspeed = 26
        repeat
            if (humanoid.MoveDirection.Magnitude > 0.1) then
            stamina = stamina - 1
            Interface:UpdateStamina()
            end
            wait(0)
        until not inputService:IsKeyDown(Enum.KeyCode.LeftControl) do

        humanoid.WalkSpeed = script.Parent.Parent.Humanoid.Walkspeed

        if (stamina <= 0) then
            wait(3) 
        else
            wait(1)
        end

        while (not inputService:isKeyDown(Enum.KeyCode.LeftControl)and stamina >= 100) do
            stamina = stamina + 0.1
            Interface:UpdateStamina()
            wait(0)
        end
    end
end
0
Are you sure it's not line 6 where you have players:LocalPlayer instead of players.LocalPlayer? General_Scripter 425 — 7y
0
uhh lemme see xVanc -1 — 7y
0
oh, no when i replaced the : with . it gave me another error at line 46 where it has )) xVanc -1 — 7y
0
You shouldn't do this on the client entirely because people can hack it. Update it on the client, manage the stamina on the server. User#15029 30 — 7y
View all comments (4 more)
0
What is the actual error? 'output says there is something wrong with the 7th line' isn't very descriptive. User#15029 30 — 7y
0
i dont know how to do that, and also the erorr is on line 7 it says, "Expected '(', '{' or <string> got 'local'" xVanc -1 — 7y
0
idk what to do when it does that xVanc -1 — 7y
0
Added an answer based on the output. User#15029 30 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

"Expected '(', '{' or <string> got 'local'" says to me that it's a syntax error. I looked at the line before and spotted something that would confuse the heck out of lua.

You have a colon on line six, so lua thinks you're calling a method or something and is expecting a parameter or just ().

Replace the : with a . on line six and you'll be just fine!

EDIT:

Looking at your new problem, you should just add an end) to end the anonymous function at line 32.

game:GetService("StarterGui"):SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)

local players = game:GetService("Players")
local inputService = game:GetService("UserInputService")

local player = players.LocalPlayer 
local character = playerCharacter or player.CharacterAdded:wait()
local humanoid = character:WaitForChild("Humanoid")

local stamina = 100

local Interface = {}
do
    local playerGui = player:WaitForChild("PlayerGui")

    local gui = playerGui:WaitForChild("Stamina")
    local frame = gui:WaitForChild("Frame")
    local textlabel = frame:WaitForChild("TextLabel")
    local bar = frame:WaitForChild("Percentage")

    local UDim2_new = UDim2.new

    function Interface:UpdateStamina()
        bar.Size = UDim2_new(stamina/100, 0, 0, 0)
        textLabel.Text = ("Stamina - 4d / 100")format(stamina)
    end


end


inputService.InputBegan:connect(function(input, event)
    if (event or stamina <= 0) then return end

    local key = input.KeyCode.Name
    print(key)

    if (key == "LeftControl") then
        humanoid.Walkspeed = 26
        repeat
            if (humanoid.MoveDirection.Magnitude > 0.1) then
            stamina = stamina - 1
            Interface:UpdateStamina()
            end
            wait(0)
        until not inputService:IsKeyDown(Enum.KeyCode.LeftControl) do

        humanoid.WalkSpeed = script.Parent.Parent.Humanoid.Walkspeed

        if (stamina <= 0) then
            wait(3) 
        else
            wait(1)
        end

        while (not inputService:isKeyDown(Enum.KeyCode.LeftControl)and stamina >= 100) do
            stamina = stamina + 0.1
            Interface:UpdateStamina()
            wait(0)
        end
    end
end
end)
0
thanks! xVanc -1 — 7y
0
Just add an 'end' and a ')' to close the anonymous function at line 32. User#15029 30 — 7y
Ad

Answer this question