I’m confused, is this only for the default animations? How do I make it work for custom animations like?
v2.0.0-alpha
This is a pre-release for v2.0.0. You will find the changelog + roblox model at the above link.
is there any way to check if the animations already loaded in the server or client?, because let’s say, when my tool play a animation and it hasn’t loaded yet, it completely breaks the system
This would be more needed for the client, since the server loads relatively fast
I’m not quite understanding what you’re saying. Could you please provide me with some code as an example?
I mean, there’s a error that breaks the script when you try to play a animation that hasn’t loaded for the character, this mostly occurs in the client, i’ll see, wait
Sorry i forgot, for example on my stun stick tool :
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local CollectionService = game:GetService("CollectionService")
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local Modules = ReplicatedStorage:WaitForChild("Modules")
local events = ReplicatedStorage:WaitForChild("Events")
local remotes = events:WaitForChild("Remotes")
local Shared = Modules.Shared
local vfx = remotes:WaitForChild("vfx")
local RemoveStaminaClient = remotes:WaitForChild("RemoveStaminaClient")
local GetCurrentStamina = remotes:WaitForChild("GetCurrentStaminaClient")
local Janitor = require(Shared:WaitForChild("Janitor"))
local ClassPP = require(Modules:WaitForChild("ClassPP"))
local class = ClassPP.class
local MaxHitbox = require(Shared:WaitForChild("MuchachoHitbox"))
local AnimationsFolder = ReplicatedStorage:WaitForChild("Animations")
local Package = AnimationsFolder:WaitForChild("Package")
local Signal = _G.Require("Signal")
local toolClass = class "Stun Stick" {
constructor = function(self, tool: Tool | Instance | Model)
if tool and tool:IsA("Tool") then
warn("Constructed "..tool.Name)
self.Tool = tool
self.debounce = false
if RunService:IsServer() then
self.Player = false
self.AnimationHandler = require(Package:WaitForChild("AnimationsServer"))
self.Tool.Equipped:Connect(function()
self.Character = tool.Parent
self.equipped = true
if not self.Character then return end
if self.Character:FindFirstChild("Humanoid") then
self.Humanoid = self.Character:FindFirstChildWhichIsA("Humanoid") or self.Character:WaitForChild("Humanoid")
end
if self.Character then
self.Player = Players:GetPlayerFromCharacter(self.Character)
end
end)
self.Tool.Unequipped:Connect(function()
if self.Character then
self.Character = false
end
if self.Player then
self.Player = false
end
self.equipped = false
end)
self.Tool.Activated:Connect(function()
if not self.equipped then return end
if not self.Character then return end
if not self.Humanoid then return end
if self.Humanoid.Health <= 0 then return end
--warn(self.Character)
end)
elseif RunService:IsClient() then
self.Player = Players.LocalPlayer
self.AnimationHandler = require(Package:WaitForChild("AnimationsClient"))
self.Tool.Equipped:Connect(function()
if self.Tool:FindFirstChild("Handle") then
self.Handle = self.Tool:WaitForChild("Handle")
end
self.Character = tool.Parent
if not self.Character then return end
if self.Character:FindFirstChild("Humanoid") then
self.Humanoid = self.Character:FindFirstChildWhichIsA("Humanoid") or self.Character:WaitForChild("Humanoid")
end
self.IdleTrack = self.AnimationHandler:PlayTrack({"ToolActions", tostring(self.Tool.Name), "Hold"})
if self.Tool then
if self.Handle:FindFirstChild("Slash") then
self.Sounds.Slash = self.Handle:WaitForChild("Slash") or self.Handle:FindFirstChild("Slash") :: Sound
end
end
self.equipped = true
end)
self.Tool.Unequipped:Connect(function()
if self.Character then
self.Character = false
end
if self.IdleTrack then
self.AnimationHandler:StopTrack({"ToolActions", tostring(self.Tool.Name), "Hold"})
self.IdleTrack = false
end
self.equipped = false
end)
self.Tool.Activated:Connect(function()
if not self.AnimationHandler:AreAllTracksLoaded(self.Player.Character or self.Character) then warn("Tracks Are Loading") return end
if not self.equipped then return end
if not self.Player then return end
if not self.Character then return end
if not self.Humanoid then return end
if self.Humanoid.Health <= 0 then return end
local Current_ST: number = GetCurrentStamina:Invoke()
if not self.debounce and Current_ST > 0 then
self.debounce = true
RemoveStaminaClient:Fire(self.Configuration.StaminaCost)
local trackSwing: AnimationTrack = self.AnimationHandler:PlayTrack({"ToolActions", tostring(self.Tool.Name), "Swing"})
if self.Sounds.Slash then
self.Sounds.Slash:Play()
end
local params = OverlapParams.new()
params.FilterType = Enum.RaycastFilterType.Exclude
params.FilterDescendantsInstances = {self.Player.Character or self.Character, self.Tool}
local newHitbox = MaxHitbox.CreateHitbox()
newHitbox.Visualizer = false
newHitbox.Size = Vector3.new(1.6, 3, 1.6)
newHitbox.DetectionMode = "HitOnce"
newHitbox.VelocityPrediction = true
newHitbox.VelocityPredictionTime = .05
newHitbox.CFrame = self.Tool.Handle
newHitbox.OverlapParams = params
newHitbox.Touched:Connect(function(hit, humanoid)
if hit then
vfx:FireServer("all", "soundManagerMisc",
"tools", "ShockSound", self.Tool.Handle.Position
)
end
if humanoid then
Signal.FireServer("HitCheck", humanoid ,
{
Damage = self.Configuration.Damage,
RagdollTimeAdd = self.Configuration.RagdollTimeAdd,
DamageType = self.Configuration.DamageType
}
)
end
end)
newHitbox:Start()
task.delay(0.45, function()
newHitbox:Stop()
end)
task.wait(self.Configuration.DebounceTime)
self.debounce = false
end
end)
end
end
end,
destructor = function(self)
end,
Public = {
Player = false,
debounce = false,
equipped = false,
Tool = false,
Handle = false,
Configuration = {
DamageType = "Melee",
Damage = 15,
DebounceTime = 1,
RagdollTimeAdd = 1.5,
StaminaCost = 5
},
Sounds = {
Slash = false,
},
IdleTrack = false,
Character = false,
Humanoid = false,
AnimationHandler = false,
OnToolRemoved = false,
},
}
return toolClass
If you try to play a animation before it loads, it errors, so a way to check if all animations have loaded in the character would be nice, so i can use it on a conditional
No, it is similar but, Since i dont find a use for it, it would be better if it was a check that returns a true or false value
Yes!, thank you so much
This text will be blurred