"Expected identifier when parsing expression, got ')'"

I have all the animations working BUT there is a problem. Roblox wants me to put end at the end of each “if false then”. I’m trying to avoid this so it results in: If NPC speed is greater than 8, play the running animation, but if the speed is currently something like 4, it will check if it has speed less than 1, if that’s the case it will play the idle animation because it has stopped moving. Finally, after this, it will check if speed is between 1-8, and if it is, it will play the walking animation.

When I do place the ends of “if false then”, it will simply break the animations and none of it will work.
Heres the script(s).
Animation according to speed (problem i have)

local Animation = game.Workspace.MIKKLE2.Humanoid.Animator
local Mikkle = Animation.Parent.Parent
local Humanoid = script.Parent.Humanoid
local RunAnim = Humanoid.Animator.RunAnim
local IdleAnim = Humanoid.Animator.IdleAnim
local WalkAnim = Humanoid.Animator.WalkAnim

-- animation cache

local b = Mikkle.Humanoid:LoadAnimation(IdleAnim)
local a = Mikkle.Humanoid:LoadAnimation(RunAnim)
local c = Mikkle.Humanoid:LoadAnimation(WalkAnim)
Mikkle.Humanoid.Running:Connect(function(speed)
	if speed > 8 then
		a:Play()
		b:Stop()
		c:Stop()
		if false then
		if speed < 1 then
			b:Play()
			a:Stop()
			c:Stop()
            if false then
			if speed > 1 then
				c:Play()
				b:Stop()
				a:Stop()
			end
		end
	end
end)

Change speed at random times

local WlkSpeed = game.Workspace.MIKKLE2.Humanoid

while true do
	WlkSpeed.WalkSpeed = 9
	wait(5)
	WlkSpeed.WalkSpeed = 6
	wait(5)
	WlkSpeed.WalkSpeed = 12
	wait(8)
	WlkSpeed.WalkSpeed = 15
	wait(12)
	WlkSpeed.WalkSpeed = 0
	wait(2)
end

Any help is appreciated

local Animation = game.Workspace.MIKKLE2.Humanoid.Animator
local Mikkle = Animation.Parent.Parent
local Humanoid = script.Parent.Humanoid
local RunAnim = Humanoid.Animator.RunAnim
local IdleAnim = Humanoid.Animator.IdleAnim
local WalkAnim = Humanoid.Animator.WalkAnim

-- animation cache

local b = Mikkle.Humanoid:LoadAnimation(IdleAnim)
local a = Mikkle.Humanoid:LoadAnimation(RunAnim)
local c = Mikkle.Humanoid:LoadAnimation(WalkAnim)
Mikkle.Humanoid.Running:Connect(function(speed)
	if speed > 8 then
		a:Play()
		b:Stop()
		c:Stop()
		if speed < 1 then
			b:Play()
			a:Stop()
			c:Stop()
			if speed > 1 then
				c:Play()
				b:Stop()
				a:Stop()
			end
		end
	end
end)

I am assuming this is the fix to whatever issue your having. If you could make it a little clearer on the issue that would be nice also tldr.

1 Like

It did fix it, but I wanted the idle and walk animation to play once NPC speed reached 0 (for idle) and 1-8 (for walking)

I fixed it! I simply used an “else” function

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.