No error, but ContextActionService could not find the function passed in, doing nothing

Not entirely sure where in my script this is a problem, but I believe it might have something to do with this?

function MobileControls.Set(active)
	if not MobileControls.IsMobile() then return end
	
	local SprintButton = ContextActionService:GetButton('Sprint')
	if not SprintButton then return end
	
	if active then
		PlayerControls:EnableActiveControlModule()
		
		SprintButton.Visible = true
	
		if TouchGui then
			TouchGui.Enabled = true
		end
	else
		PlayerControls:Disable()
		
		SprintButton.Visible = false
		
		if TouchGui then 
			TouchGui.Enabled = false 
		end
	end
end

I added if not SprintButton then return end thinking it wasn’t finding the sprint button (sprint button is only available to those who have a gamepass)

2 Likes