Hey! I have a sword that has 5 parts. I’m trying to make it so that if you move the handle, the entire sword moves. However, I’m not sure how I would do this… Here is my code:
local Event = script.Parent
Event.OnServerEvent:Connect(function(Player, Action)
local c = Player.Character
local Sword = script.Sword
if Action == "Wield" then
local Clone = Sword:Clone()
Clone.Parent = c
Clone.HandleBase.Position = c.RightHand.Position
local Weld = Instance.new("WeldConstraint", Clone)
Weld.Part0 = c.RightHand
Weld.Part1 = Clone.PrimaryPart
end
end)
Not quite sure why you’re only welding the sword when an event has been fired or that the sword isn’t placed in a players inventory but there is an easier way to do this.
Just create a tool, insert your 5 sword parts into the tool and name whichever part you want it to be held from as “Handle”. You can then use the in-studio weld tool to connect the parts of your sword, like so:
You can then place this tool in ServerStorage (or wherever you want to store it that can properly replicate) and clone/place it as needed. Obviously yours won’t look exactly like mine, but the parts are all connected so you get the point.
From there, you can edit the Grip properties of the tool to make sure the player is holding it exactly how you want them to. You can do this manually by going into a play test and adjusting it from there then copying the tool with the updated grip, or if you have 5 robux you can get this plug-in to adjust the grip: Tool Grip Editor - Roblox (I personally use this and it works very well). However, doing it manually isn’t that hard, just takes some trial and error.