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

Dosent weld part to the front of the player?

I have a script where it welds a certain part to the front of the player. But it isnt working. Can someone help me?

local module = {}
function module.gui(plr)
	local player = game.Players:WaitForChild(plr)
	script.Part.Position = CFrame.new(player.Character.Head.Position + Vector3.new(0, 10, 0))
	local weld = Instance.new("WeldConstraint", script.Part)
	weld.Part0 = script.Part
	weld.Part1 = player.Character.Head
end
return module

1 answer

✓ Accepted answer

first, you need to check if player is added. then, check if the character is added and you need to clone the part to make it works to every player This is the module:

return function(player)
	local char = player.Character
	local Clone = script.Part:Clone()
	Clone.Parent = char.Head
	Clone.Position = char.Head.Position + Vector3.new(0, 10, 0)
	local weld = Instance.new("WeldConstraint", Clone)
	weld.Part0 = Clone
	weld.Part1 = char.Head
end

this is the script to check:

game.Players.PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(function(char) --Check The Character is loaded
		require(script.ModuleScript)(Player)
	end)
end)

try that and the part is above your player head, if this work please mark as an answer!:)

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