Ad
Log in to vote
0

There is this error that I cant fix how do I fix it? I'm trying to make a sprint script.

Asked by
CMB1048 23
1 year ago
Edited 1 year ago

Error: 12:55:56.743 Players.CMB1048.PlayerScripts.LocalScript:22: Expected 'end' (to close 'then' at line 13), got <eof>; did you forget to close 'then' at line 18? - Studio - LocalScript:22

UserInputService = game:GetService("UserInputService")
local players = game.Players.LocalPlayer



local UserInputService = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()

UserInputService.InputBegan:Connect(function(input,gameProcessed)
    --if not gameProcessed then
    if input.KeyCode == Enum.KeyCode.LeftShift then
        if players:FindFirstChild("Humanoid") then
            players.Humanoid.CharacterWalkSpeed = 90

            UserInputService.InputEnded:Connect(function(input,gameProcessed)
                if input.KeyCode == Enum.KeyCode.LeftShift then
                    if players:FindFirstChild("Humanoid") then
                        players.Humanoid.CharacterWalkSpeed = 16
                    end
                end
            end)

1 answer

Log in to vote
0
Answered by 1 year ago

You didn't close your if statements and your function. I just added "ends"

UserInputService = game:GetService("UserInputService")
local players = game.Players.LocalPlayer



local UserInputService = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()

UserInputService.InputBegan:Connect(function(input,gameProcessed)
    --if not gameProcessed then
    if input.KeyCode == Enum.KeyCode.LeftShift then
        if players:FindFirstChild("Humanoid") then
            players.Humanoid.CharacterWalkSpeed = 90

            UserInputService.InputEnded:Connect(function(input,gameProcessed)
                if input.KeyCode == Enum.KeyCode.LeftShift then
                    if players:FindFirstChild("Humanoid") then
                        players.Humanoid.CharacterWalkSpeed = 16
                        end
                    end
                end)
            end
        end

            end)
Ad

Answer this question