My animations aren’t playing correctly.
I animated a sword on my animation and it isn’t moving in the animation, along with it just looking off
What it’s supposed to look like:
robloxapp-20240927-2238325.wmv (309.7 KB)
What it looks like in game:
robloxapp-20240927-2239024.wmv (762.8 KB)
Could it be how I apply the Motor6Ds?
Also, if I set the dummy as the StarterCharacter, the animation works fine.
Pictures of the explorer:
M1Hitbox is the name I’m using for the sword model
Script that sets up the welds:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local WCS = require(ReplicatedStorage.WCS)
local Fiend = require(ReplicatedStorage.movesets.Fiend)
local Hamon = require(ReplicatedStorage.movesets.Sword)
local Character = WCS.Character
local Welds = {}
local currentMovesets = {} -- Store current movesets for each player
Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(CharacterModel)
-- Function to apply moveset to a character
local function applyMoveset(CharacterModel, movesetName)
-- Remove existing M1Hitbox if present
local existingHitbox = CharacterModel:FindFirstChild("M1Hitbox")
if existingHitbox then
existingHitbox:Destroy()
end
-- Clean up any previous moveset for this character
if currentMovesets[Player] then
currentMovesets[Player]:Destroy()
end
-- Create the WCS Character instance
local WCS_Character = Character.new(CharacterModel)
CharacterModel:SetAttribute("CurrentMoveset", movesetName)
local currentMoveset = CharacterModel:GetAttribute("CurrentMoveset")
-- Apply the new moveset
WCS_Character:ApplyMoveset(movesetName)
-- Apply hitboxes
local Hitbox = ReplicatedStorage.movesets[movesetName].Info.Hitboxes
local M1Hitbox = Hitbox.M1Hitbox:Clone()
M1Hitbox.Name = "M1Hitbox" -- Ensure the hitbox has a consistent name
M1Hitbox.Parent = CharacterModel
if currentMoveset == "Fiend" then
Welds[Player] = M1Hitbox.M1HitboxWeld:Clone()
Welds[Player].Parent = CharacterModel["Torso"]
Welds[Player].Part0 = CharacterModel["Torso"]
Welds[Player].Part1 = M1Hitbox
end
if currentMoveset == "Sword" then
Welds[Player] = M1Hitbox.WeaponWeld:Clone()
Welds[Player].Parent = CharacterModel["Right Arm"]
Welds[Player].Part0 = CharacterModel["Right Arm"]
Welds[Player].Part1 = M1Hitbox
end
-- Save the applied moveset
currentMovesets[Player] = WCS_Character
-- Destroy it when humanoid dies
local Humanoid = CharacterModel:WaitForChild("Humanoid")
Humanoid.Died:Once(function()
WCS_Character:Destroy()
end)
end
-- Initially apply the default moveset
applyMoveset(CharacterModel, "Fiend")
-- Swap moveset based on chat input
Player.Chatted:Connect(function(msg)
local args = string.split(msg, " ")
if args[1] == "!swap" and args[2] then
local movesetName = args[2]
-- Check if the moveset exists in ReplicatedStorage
if ReplicatedStorage.movesets:FindFirstChild(movesetName) then
-- Apply the new moveset to the character
applyMoveset(CharacterModel, movesetName)
else
Player:Kick("Moveset '" .. movesetName .. "' does not exist!")
end
end
end)
end)
end)