Error with playing animation while trying to use ContextActionService


 I have currently been trying to get some of my movement system to work on mobile in my game and ran into an issue where in my function it will not play my animations or fire my events. I am using ContextActionService for this and have not encountered this issue any other time I have used CAS. I recently just made a crouching system with CAS which is almost exactly the same code as my sliding script and it works perfectly fine. I even plugged the slide animation into it and it worked fine. This issue only persits in my sliding script. I tried creating a new script which I arranged and cleaned up the code but still the same error. I have looked on the web but have found nothing that gives me a good solution. If anyone else has encountered this issue or knows how to fix it, please let me know.

Here is my sliding code(new to studio so please excuse my bad coding and organization):

local player = game.Players.LocalPlayer
local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")
local rootPart = humanoid.RootPart
local Camera = workspace.CurrentCamera

local RunService = game:GetService("RunService")
local UIS = game:GetService("UserInputService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ContextActionService = game:GetService("ContextActionService")
local GuiService = game:GetService("GuiService")

--sliding varibles
local isSliding = false
local justSlided = false
local slideForce = 1.6
local slideCooldown = .8
local grounded = true
local justSlided = false
local canNotSlide = false
local lateGrounded = true

local CameraInfo =
local CameraTweenDown = game:GetService("TweenService"):Create(player.Character.Humanoid, CameraInfo, {CameraOffset =,-2.5,1)})
local CameraTweenUp = game:GetService("TweenService"):Create(player.Character.Humanoid, CameraInfo, {CameraOffset =,0,0)})

local isSlidingEvent = ReplicatedStorage:WaitForChild("isSliding")
local stoppedSlidingEvent = ReplicatedStorage:WaitForChild("stoppedSliding")
local SlidingStart = ReplicatedStorage:WaitForChild("SlidingStart")
local SlidingStop = ReplicatedStorage:WaitForChild("SlidingStop")

local Slide = humanoid:LoadAnimation(script:WaitForChild("SlideAnim"))

--check if grounded
humanoid.StateChanged:Connect(function(oldState, newState)
	if newState == Enum.HumanoidStateType.Jumping then
		grounded = false

humanoid.StateChanged:Connect(function(oldState, newState)
	if newState == Enum.HumanoidStateType.Landed then
		grounded = true
		lateGrounded = false

--actual sliding code
local function Slide(name, state, input)
	if state == Enum.UserInputState.Begin and not isSliding then
		isSliding = true
		local hVel = character.HorizontalVelocity
		hVel.Value = hVel.Value * slideForce
		isSliding = false
		justSlided = true
		canNotSlide = true
		canNotSlide = false

ContextActionService:BindAction("Sliding", Slide, true, Enum.KeyCode.LeftShift)
ContextActionService:SetPosition("Sliding",, 0, .5, 0))
ContextActionService:SetTitle("Sliding", "Slide")

--check if on mobile
if UIS.TouchEnabled and not UIS.KeyboardEnabled and not UIS.MouseEnabled and not UIS.GamepadEnabled and not GuiService:IsTenFootInterface() then
	local CrouchButton = ContextActionService:GetButton("Sliding")
	CrouchButton.Size =,0,.35,0)

Screenshot of error in output:

You have two variables named “Slide” that are conflicting with each other.

The first is an AnimationTrack.

The second is a function.

It is trying to call :Play() and :Stop() on the function Slide rather than the AnimationTrack of the same name.

Can’t believe I didn’t notice this, thanks man.

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