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 just want to load animations.
- What is the issue? Include screenshots / videos if possible!
Apparently it’s due to a roblox bug, I’ve tried using these lines of codes, but it still gives the error
local character =player.Character or player.CharacterAdded:Wait()
repeat
task.wait()
until character:IsDescendantOf(workspace)
can’t find anything on the developper hub ![]()
local ContextActionService=game:GetService("ContextActionService")
local RS= game:GetService("ReplicatedStorage")
local BoxingGuardEvent= RS.eventsAndFunctions.BoxingGuardEvent
local RunService = game:GetService("RunService")
local Players = game:GetService("Players")
local player= Players.LocalPlayer
local character =player.Character or player.CharacterAdded:Wait()
repeat
task.wait()
until character:IsDescendantOf(workspace)
local Humanoid = player.character:WaitForChild("Humanoid")
local ispair=2 -- ispair makes it so that
local Animator=Instance.new("Animator")
--the jab
local JabAnimation=Instance.new("Animation")
JabAnimation.AnimationId="rbxassetid://13082182573"
local JabAnimationTrack=Animator:LoadAnimation(JabAnimation)
--the cross
local CrossAnimation=Instance.new("Animation")
CrossAnimation.AnimationId="rbxassetid://13044212329"
local CrossAnimationTrack=Animator:LoadAnimation(CrossAnimation)
-- goes into boxing guard after one 'R' key press, goes back to normal after another R' key press
local function BoxingGuard(actionName, userInputState, inputObject)
if actionName == "IdleBoxingGuard" and userInputState == Enum.UserInputState.End then
if ispair % 2 ==0 then -- if it's pair
BoxingGuardEvent:FireServer(ispair)
ContextActionService:BindAction("jab",jabbing,false,Enum.UserInputType.MouseButton1)
print("In boxing guard")
else -- if it's not pair
BoxingGuardEvent:FireServer(ispair)
print("back to normal Idle")
end
ispair+=1
end
end
local function jabbing(actionName, inputState, _inputObject)
if actionName=="jab" and inputState == Enum.UserInputState.Begin then
JabAnimationTrack:Play()
end
end
ContextActionService:BindAction("IdleBoxingGuard",BoxingGuard,false,Enum.KeyCode.R)