I finally got the welding to work (welding a knife onto a player’s hand) however, I’m not quite sure what to do after this for detecting a weld. The knife isn’t a Tool by the way.
I want to make it so that if a player has a knife welded to their hand, the Server (or Client) detects it and allows them to use knife slash animations.
You need to parent the weld constraint to the player and then give it a unique name.
function Detection()
for _,obj in pairs(character:GetDescendants()) do
if obj.Name == "Knife Weld" then
character:SetAttribute("Equipped Knife", true)
return
end
end
character:SetAttribute("Equipped Knife", false)
end)
Detection()
Before Playing the Anims make the Client/Server Aware of what Item the player is Holding by referencing that item in the script. Based on that Reference play the animations.
--Example:
If Character:FindFirstChild("KnifeWeaponModel") then
---- Play Animations here .... etc+
end
The code in which you weld the script puts a Value inside of the Player and if that Value is present then when animations are being played make the animations played correspond to that value.
--Example:
If Player:FindFirstChild("Knife").Value == true then
---- Play Animations here .... etc+
end
Make it a tool and give it a Idle Animation
--Example:
local Tool = script.Knife
Tool.Equipped:Connect(function()
---- Play Animations here .... etc+
end)
These are only 3 out of many ways to be creative !!!
Side Tip #1 Parent the KnifeClone after you have Finished Positioning and Welding will make it more accurate and efficient as the program reads code line by line it executes in the order of operation. Better to have something set up prior to it not being nil. (Can get in-depth but that’s not the main focus)
Side Tip #2 Put the Knife in the Character as it will make the workspace more Organized and there won’t be 25 Knife instances in the workspace. OR Create a folder in the workspace where the knives are stored.