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

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

Error: 12:55:56.743 Players.CMB1048.PlayerScripts.LocalScript:22: Expected 'end' (to close 'then' at line 13), got ; 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

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)

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