You can write your topic however you want, but you need to answer these questions:
- What do you want to achieve? Keep it simple and clear!
I’m starting a combat system, and when I press ‘R’ I want to go into, or get out of fighting mode.
- What is the issue? Include screenshots / videos if possible!
I’d like for ContextActionService to fire after pressing and releasing the key ‘R’.
But it currently only detects the press.
After searching for some while, didin’t find anyhting.
-- Start of variables
local ContextActionService=game:GetService("ContextActionService")
local Players = game:GetService("Players")
local player= Players.LocalPlayer
local Character = player.Character or player.CharacterAdded:Wait()
local Humanoid = player.Character:WaitForChild("Humanoid")
local animator= Humanoid:WaitForChild("Animator")
local animation= Instance.new("Animation")
animation.AnimationId="rbxassetid://13055232360"
local ispair= 1 -- this will help detect if I need to stop or play animation
localanimationTrack = animator:LoadAnimation(animation)
-- End of variables
local function BoxingGuard()--replace idle anim by new one
if ispair % 2==0 then -- if it's pair
localanimationTrack:Stop()
print("stop pressing R")
else -- if it's not pair
localanimationTrack:Play()
print("press button R")
end
ispair+=1
end
ContextActionService:BindAction("IdleBoxingGuard",BoxingGuard,false,"r")
Do you know how can I make it so that ContextActionService fires the function after press and release of ‘R’.