Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Can't get my sword to stay in the players hand? [SOLVED]

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

2 answers

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.

3 comments

0

Glad you figured it out. It'd be good if you edited the title of this question to have "[Solved]" in the title so others won't read your question unnecessarily.

0

Will do

0

I'm having the same problem, but my sword has a lot of parts, and won't stay connected to the character no matter what

You don't need to weld but make sure tool.NeedHandle is true and the handle name it Handle

1 comment

0

It was true and I already fixed it, thanks.

This discussion is preserved as it was. New answers, comments, and votes are closed.