I have recently started to learn about ContextActionService, and I have rebinded the space key so it makes a player dash. The problem is, I am making a cutscene with the player in it. The problem is that the player can still dash during the cutscene, making it shorter than it should be.
Is there a way to unbind a custom action using ContextActionService?
if not game:IsLoaded() then game.Loaded:Wait() end
local ContextActionService = game:GetService("ContextActionService")
ContextActionService:UnbindAction("jumpAction")
local UserInputService = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local invincibility = false
local dashCooldown = false
character:WaitForChild("Humanoid").JumpPower = 0
function mobileDashPress()
if dashCooldown == false then
invincibility = true
dashCooldown = true
character.Humanoid.WalkSpeed = 75
wait(0.4)
character.Humanoid.WalkSpeed = 16
wait(0.25)
dashCooldown = false
invincibility = false
end
end
local mobileButton = ContextActionService:BindAction("DashButton", mobileDashPress, true, Enum.KeyCode.Space)
local DashButton = ContextActionService:GetButton("DashButton")
ContextActionService:SetPosition("DashButton", UDim2.new(1, -95,1, -90))
ContextActionService:SetImage("DashButton","http://www.roblox.com/asset/?id=5853926901")
DashButton.Size = UDim2.new(0, 70,0, 70)
wait(1)
ContextActionService:UnbindAction("DashButton")
if not game:IsLoaded() then game.Loaded:Wait() end
local ContextActionService = game:GetService("ContextActionService")
ContextActionService:UnbindAction("jumpAction")
local UserInputService = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local invincibility = false
local dashCooldown = false
character:WaitForChild("Humanoid").JumpPower = 0
function mobileDashPress()
if dashCooldown == false then
invincibility = true
dashCooldown = true
character.Humanoid.WalkSpeed = 75
wait(0.4)
character.Humanoid.WalkSpeed = 16
wait(0.25)
dashCooldown = false
invincibility = false
end
end
ContextActionService:BindAction("DashButton", mobileDashPress, true, Enum.KeyCode.Space)
local DashButton = ContextActionService:GetButton("DashButton")
ContextActionService:SetPosition("DashButton", UDim2.new(1, -95,1, -90))
ContextActionService:SetImage("DashButton","http://www.roblox.com/asset/?id=5853926901")
DashButton.Size = UDim2.new(0, 70,0, 70)
task.wait(1)
ContextActionService:UnbindAction("DashButton")