Error I cant solve

My run/walk script is having an error at the 2 ends with brackets cant figure out why.
The error is Expected identifier when parsing expression, got ‘)’

local UIS = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local humanoid = player.Character.Humanoid
local RunService = game:GetService("RunService")
local anim = Instance.new("Animation")
anim.AnimationId = "rbxassetid://9782831813"

local playanim = humanoid:LoadAnimation(anim)

UIS.InputBegan:Connect(function(key)
	if key.KeyCode == Enum.KeyCode.LeftShift then
		script.Parent:WaitForChild("Humanoid").WalkSpeed = 30
		if script.Parent.Humanoid then
			playanim:Play()
	end
end)
		

UIS.InputEnded:Connect(function(key)
	if key.KeyCode == Enum.KeyCode.LeftShift then
		script.Parent:WaitForChild("Humanoid").WalkSpeed = 16
		if script.Parent.Humanoid then
			playanim:Stop()
	end
end)
2 Likes

It looks like you’re missing the ends for these conditional blocks.

3 Likes

Thx lol I don’t how I didn’t see that.

3 Likes

Before the Luau ternary operator update, i’m pretty sure errors like these were highlighted in the relevant areas in the script editor. Now it seems that the error is highlighted almost arbitrarily, usually at an “end”. Might be something to look at

1 Like