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

(?) So I was trying to make a sword that goes on the hip but it doesn't work

So I was making a sword that goes on the hip but when I finish it and test play it the sword is not on the hip and you can't see the sword. I used the Classic Sword made by roblox and insert a local script in it and type this

while wait do 
	if script.Parent.Parent.Name == "Backpack" then
		local Character = script.Parent.Parent.Parent.Character
		
		if Character then
			local Torso = Character:FindFirstChild("UpperTorso")
			local Weapon = Character:FindFirstChild(script.Parent.Name)
			
			if Torso and not Weapon then
				local WeaponOnHip = Instance.new("Model")
				WeaponOnHip.Name = script.Parent.Name
				WeaponOnHip.Parent = Character
				
				Handle = script.Parent.Handle:Clone()
				Handle.Name = "Handle"
				Handle.Parent = WeaponOnHip
				
				local LegWeld = Instance.new("Weld")
				LegWeld.Name ="WeldOnLeg"
				LegWeld.Part0 = Torso
				LegWeld.Part1 = Handle
				LegWeld.C0 = CFrame.new(1,-1.42,0.5)
				LegWeld.C0 = LegWeld.C0 * CFrame.fromEulerAnglesXYZ(math.rad(-150),math.rad(-180),-20.5)
			end
		end
		
	else
		if Handle.Parent then
			Handle.parent:Destroy()
		end
	end
end

And there's no error in the output

6 comments

0

Try putting it in serverscriptservice

0

didn't work

0

didn't work

0

I mean serverscriptservice. Not local script.

0

you should make a varible for line 22 then set the C0 to that varible plus the equation?

0

The only error was that you forgot the bracket on line 1. While wait() do

1 answer

This is how to fix it

while wait() do
	if script.Parent.Parent.Name == "Backpack" then
		local Chararacter = script.Parent.Parent.Parent.Character
		
		if Chararacter then
	  		local Torso = Chararacter:FindFirstChild("UpperTorso")
	  		local Weapon = Chararacter:FindFirstChild(script.Parent.Name)
	
	  		if Torso and not Weapon then
		   		local WeaponOnHip  = Instance.new("Model")
		   		WeaponOnHip .Name = script.Parent.Name
		   		WeaponOnHip .Parent = Chararacter
		
		   		Handle = script.Parent.Handle:Clone()
			    Handle.Name = "Handle"
			    Handle.Parent = WeaponOnHip 
			
			    local LegWeld = Instance.new("Weld")
			    LegWeld.Name = "WeldOnLeg"
			    LegWeld.Part0 = Torso
			    LegWeld.Part1 = Handle
			    LegWeld.C0 = CFrame.new(1,-1.42,0.5)
			    LegWeld.C0 = LegWeld.C0 * CFrame.fromEulerAnglesXYZ(math.rad(-150),math.rad(-180),-20.5)
			    LegWeld.Parent = Handle
	  		end
		end

	else
		if Handle.Parent then 
	  		Handle.Parent:Destroy()
	 	end
	end
	
end

This is the fixed script

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