Hello, I’m developer Rot.
I’ll discuss this issue with answers to the following three questions:
- What do you want to achieve? I want to know how to perform Equip and Holster without any delay using Motor6D Grip.
- What is the issue? There’s a problem where welding is delayed when equipping a Tool due to the delay with Motor6D Grip.
- What solutions have you tried so far? I’ve attempted to perform welding on the client-side, but it didn’t resolve the issue as welding also needs to be done on the server. Currently, I’m searching for solutions on the Developer Hub.
Additionally, if you have any further information or assistance to offer, I would appreciate it!
Client Script:
local tool = script.Parent
local plr = tool.Parent.Parent
local char = plr.Character or plr.CharacterAdded:Wait()
local e = char.Humanoid:LoadAnimation(script.Equip)
local i = char.Humanoid:LoadAnimation(script.Idle)
local holsterService = require(game.ReplicatedStorage.HolsterService)
holsterService.SetLibrary(char) -- Where your weapons are stored, it will automatically default to what I put here
local weapon = holsterService.createWeapon("ItemModel", char) -- Make sure that the string is the weapon model and that it's in your library, and char is the model you want to hold the weapon
weapon:Holster("Torso", tool.UnequipGrip.C0) -- Arg 1 is the part of the model you want the weapon to weld to, Arg 2 is the C0
script.Parent.Equipped:Connect(function()
print("E")
weapon:Sheath("Right Arm", CFrame.new(0,0,0)) -- Arg 1 is the part of the model you want the weapon to weld to, Arg 2 is the C0
e:Play()
i:Play()
holsterService.SetLibrary(char) -- Where your weapons are stored, it will automatically default to what I put here
end)
script.Parent.Unequipped:Connect(function()
print("U")
e:Stop()
i:Stop()
weapon:Holster("Torso", tool.UnequipGrip.C0)
holsterService.SetLibrary(char) -- Where your weapons are stored, it will automatically default to what I put here
end)
Server Script:
local tool = script.Parent
local plr = tool.Parent.Parent
local char = plr.Character or plr.CharacterAdded:Wait()
local holsterService = require(game.ReplicatedStorage.HolsterService)
holsterService.SetLibrary(script.Parent) -- Where your weapons are stored, it will automatically default to what I put here
local weapon = holsterService.createWeapon("ItemModel", char) -- Make sure that the string is the weapon model and that it's in your library, and char is the model you want to hold the weapon
weapon:Holster("Torso", tool.UnequipGrip.C0) -- Arg 1 is the part of the model you want the weapon to weld to, Arg 2 is the C0
script.Parent.Equipped:Connect(function()
print("E")
weapon:Sheath("Right Arm", CFrame.new(0,0,0)) -- Arg 1 is the part of the model you want the weapon to weld to, Arg 2 is the C0
holsterService.SetLibrary(char) -- Where your weapons are stored, it will automatically default to what I put here
end)
script.Parent.Unequipped:Connect(function()
print("U")
weapon:Holster("Torso", tool.UnequipGrip.C0)
holsterService.SetLibrary(char) -- Where your weapons are stored, it will automatically default to what I put here
end)
Holster Service Module:
local HolsterService = {}
local weapons = {}
local weaponModels
local currentW6D, currentHolsterWeld = {},{}
function HolsterService.SetLibrary(library)
weaponModels = library
end
function HolsterService.createWeapon(weapon, model)
local weapon = weaponModels:FindFirstChild(weapon)
if weapon then
weapon.Parent = model
return setmetatable({Weapon = weapon, Owner = model}, {__index = weapons})
end
end
function weapons:Holster(limb, C0)
local weapon = self.Weapon
local model = self.Owner
if model:FindFirstChild(limb) then
if currentW6D[weapon] then currentW6D[weapon]:Destroy() end
local weld = Instance.new("Weld", model[limb])
weld.Part0 = model[limb]
weld.Part1 = weapon:WaitForChild("Handle")
weld.Name = "HolsterWeld "..weapon.Name
weld.C0 = C0
currentHolsterWeld[weapon] = weld
else
warn("Limb not found! Make sure your object is loaded in!")
end
end
function weapons:Sheath(limb, C0)
local weapon = self.Weapon
local model = self.Owner
if model:FindFirstChild(limb) then
if currentHolsterWeld[weapon] then currentHolsterWeld[weapon]:Destroy() end
local w6d = Instance.new("Motor6D", model[limb])
w6d.Part0 = model[limb]
w6d.Part1 = weapon:WaitForChild("Handle")
w6d.Name = "Weapon6D "..weapon.Name
w6d.C0 = C0
currentW6D[weapon] = w6d
else
warn("Limb not found! Make sure your object is loaded in!")
end
end
return HolsterService