I have a sword and when you press a key it switches into a gun then after a delay back into a sword. Everything is fine in Studio, of course...but in the game when it's switching from sword to gun the weld/position become weird. Then sword will still be equipped to the player but it will be floating off somewhere instead of in the player's hand. I created a script to for the weld to fix itself but that hasn't seemed to work.
local Player = game.Players.LocalPlayer char = Player.Character while wait() do local w1 = Instance.new("Weld", char) w1.Part0 = char["Right Arm"] w1.Part1 = script.Parent.Handle w1.C1 = CFrame.fromEulerAnglesXYZ(math.rad(90),0,0) *CFrame.new(0, 1.1, 0) --Forcing the sword to stay welded in the players hand end
Fixed it. I had it removing and cloning a new sword on every keypress but I did some research and found the equip and unequip methods.
You don't need to weld but make sure tool.NeedHandle is true and the handle name it Handle