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

Help With Weld?

local player = game.Players.LocalPlayer

while true do
	wait(.5)
	local weldedwep = player.Character:FindFirstChild("weldedwep")
	if weldedwep then
		local wep = player.Equiped.Value
		if wep.Value == "Default" then
			weld = Instance.new("Weld")
			weld.Part0 = player.Character.Torso
			weld.C0 = player.Character.Torso.CFrame:inverse()
			local wepmf = game.ReplicatedStorage.WeaponModels:FindFirstChild(wep)
			if wepmf then
				wepm = wepmf:Clone()
				wepm.Parent = player.Character
				weld.Part1 = wepm
			end
			
		end
	end
end

This doesn't work at all and I'm getting no errors. I'm working on a thing where the weapon is welded to the player's back. Help?

1 answer

There are multiple errors in this. I'll list them off for you.

  • 1) Misspelling on line 7
local wep = playerr.Equiped.Value

Spell it correctly;

local wep = player.Equipped.Value

  • 2) You never assigned a parent to the weld

Give it a parent;

local tor = player.Character.Torso
weld = Instance.new("Weld",tor)

Final Product;

local player = game.Players.LocalPlayer
repeat wait() until player.Character

while wait(.5) do
	local weldedwep = player.Character:FindFirstChild("weldedwep")
	if weldedwep then
		local wep = player.Equipped.Value
		if wep.Value == "Default" then
			local tor = player.Character.Torso
			weld = Instance.new("Weld",tor)
			weld.Part0 = tor
			weld.C0 = tor.CFrame:inverse()
			local wepmf = game.ReplicatedStorage.WeaponModels:FindFirstChild(wep)
			if wepmf then
				wepm = wepmf:Clone()
				wepm.Parent = player.Character
				weld.Part1 = wepm
			end
		end
	end
end

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