Hello, I’m making a sword combat system. So far I made that you can equip the sword from its case to the Players right arm, like so:
But the problem is that the sword is held in the middle of the arm, as shown in the picture. I want it to be lower so that it’s more realistic. Like this:
The script:
local rp = game:GetService("ReplicatedStorage")
local sword = rp:WaitForChild("Sword")
local cframes = {
["Right Arm"] = CFrame.new(0, -1, 0),
["Right Hand"] = CFrame.new(0, 0, 0),
}
sword.OnServerEvent:Connect(function(Player, isEquipped)
local Character = Player.Character
local Humanoid = Character.Humanoid
if isEquipped then
-- Equipping the sword
local Katana = Character:FindFirstChild("Katana")
if Katana then
local SideWeld = Katana.PrimaryPart:FindFirstChild("SideWeld")
if SideWeld then
SideWeld:Destroy()
----------------------------------------------------------------------------------------------------------------
if Humanoid.RigType == Enum.HumanoidRigType.R15 then
Katana:SetPrimaryPartCFrame(Character:WaitForChild("Right Hand").CFrame * cframes["Right Hand"])
elseif Humanoid.RigType == Enum.HumanoidRigType.R6 then
Katana:SetPrimaryPartCFrame(Character:WaitForChild("Right Arm").CFrame * cframes["Right Arm"])
end
local HandWeld = Instance.new("ManualWeld")
HandWeld.Part0 = Katana.PrimaryPart
-------------------------------------------------------------------------------- --------------------------------
if Humanoid.RigType == Enum.HumanoidRigType.R15 then
HandWeld.Part1 = Character:WaitForChild("Right Hand")
elseif Humanoid.RigType == Enum.HumanoidRigType.R6 then
HandWeld.Part1 = Character:WaitForChild("Right Arm")
end
HandWeld.C0 = HandWeld.Part1.CFrame:ToObjectSpace(HandWeld.Part1.CFrame)
HandWeld.Parent = HandWeld.Part0
----------------------------------------------------------------------------------------------------------------
end
end
elseif not isEquipped then
--Unequipping the sword
end
end)
I’ve already tried to change the CFrames in the cframes
table, but it didn’t work.
Please help and thank you.
EDIT: the sword isn’t a tool, it spawns when you join the game.