SO im trying to weld a part to a player but im not sure how, please help
local shield = game.ReplicatedStorage.shield:Clone()
game.Players.PlayerAdded:Connect(function(player)
local character = player.Character or player.CharacterAdded:Wait()
shield.Parent = character
local weld = Instance.new("WeldConstraint")
weld.Part0 = shield
weld.Part1 = character.HumanoidRootPart
weld.Parent = character
shield.IsInUse.Value = true
end)
local shield = game.ReplicatedStorage.shield:Clone()
local player = game.Players.PlayerAdded:Wait()
local character = player.CharacterAdded:Wait() or workspace[player.Name]
spawn(function()
local weld = Instance.new("Weld", shield)
weld.Part0 = shield
weld.Part1 = character.HumanoidRootPart
weld.C0 = CFrame.new(0, 0, 0) *CFrame.new(0, 0, 0)
end)
Check in the explorer while play testing if the weld exists. The problem might be the positioning. With WeldConstraints, you can adjust the position and orientation with the .Position and .Orientation properties.
I’d recommend trying something like this:
local shield = game.ReplicatedStorage.shield:Clone()
game.Players.PlayerAdded:Connect(function(player)
local character = player.Character or player.CharacterAdded:Wait()
shield.Parent = character
local weld = Instance.new("WeldConstraint")
weld.Parent = character
weld.Part0 = shield
weld.Part1 = character.HumanoidRootPart
sheild.Position = character.HumanoidRootPart.Position
shield.IsInUse.Value = true
end)
To better position the Shield, you can add character.HumanoidRootPart.CFrame.LookVector * constant and character.HumanoidRootPart.CFrame.RightVector * constant to adjust the shield. You can also set the orientation of the shield to character.HumanoidRootPart.Orientation.