Answered by
8 years ago Edited 8 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.
01 | game:GetService( "StarterGui" ):SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false ) |
03 | local players = game:GetService( "Players" ) |
04 | local inputService = game:GetService( "UserInputService" ) |
06 | local player = players.LocalPlayer |
07 | local character = playerCharacter or player.CharacterAdded:wait() |
08 | local humanoid = character:WaitForChild( "Humanoid" ) |
14 | local playerGui = player:WaitForChild( "PlayerGui" ) |
16 | local gui = playerGui:WaitForChild( "Stamina" ) |
17 | local frame = gui:WaitForChild( "Frame" ) |
18 | local textlabel = frame:WaitForChild( "TextLabel" ) |
19 | local bar = frame:WaitForChild( "Percentage" ) |
21 | local UDim 2 _new = UDim 2. new |
23 | function Interface:UpdateStamina() |
24 | bar.Size = UDim 2 _new(stamina/ 100 , 0 , 0 , 0 ) |
25 | textLabel.Text = ( "Stamina - 4d / 100" )format(stamina) |
32 | inputService.InputBegan:connect( function (input, event) |
33 | if (event or stamina < = 0 ) then return end |
35 | local key = input.KeyCode.Name |
38 | if (key = = "LeftControl" ) then |
39 | humanoid.Walkspeed = 26 |
41 | if (humanoid.MoveDirection.Magnitude > 0.1 ) then |
43 | Interface:UpdateStamina() |
46 | until not inputService:IsKeyDown(Enum.KeyCode.LeftControl) do |
48 | humanoid.WalkSpeed = script.Parent.Parent.Humanoid.Walkspeed |
50 | if (stamina < = 0 ) then |
56 | while ( not inputService:isKeyDown(Enum.KeyCode.LeftControl) and stamina > = 100 ) do |
57 | stamina = stamina + 0.1 |
58 | Interface:UpdateStamina() |