How would I weld a part to a player?

I’m making a shield script but the shield has a part inside it which is welded to the shield using a Motor6D from Moon Animator’s easy weld. When the shield is activated, every time I move, I sort of fling a bit.

I use a WeldConstraint to attach the part inside the shield to my humanoid root part.

Server Script in ServerScriptService:

game.Lighting.RemoteEvents.JeanEventsX.ForceFieldStart.OnServerEvent:Connect(function(plr)
	local Character = plr.Character
	local ForceFieldAnimation = Character.Humanoid:LoadAnimation(script.ForceField)
	local ForceField = game.ReplicatedStorage.ForceField:Clone()
	ForceField.Parent = Character
	ForceField.Position = Character.HumanoidRootPart.Position
	local weld = Instance.new("WeldConstraint",ForceField)
	weld.Part0 = Character.HumanoidRootPart
	weld.Part1 = ForceField.Part
	local TweenService = game:GetService("TweenService")
	local TweenInfoX = TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.Out)
	local TweenProperties = {
		Scale = Vector3.new(3.653, 3.653, 3.653)
	}
	local Tween = TweenService:Create(ForceField.Mesh, TweenInfoX, TweenProperties)
	Tween:Play()
	if game.Workspace.ForceFieldOn.Playing == false then
		game.Workspace.ForceFieldOn.Playing = true
	end
	wait(.1)
	ForceFieldAnimation:Play()
	if game.Workspace.ForceField.Playing == false then
		game.Workspace.ForceField.Playing = true
	end
end)

game.Lighting.RemoteEvents.JeanEventsX.ForceFieldEnd.OnServerEvent:Connect(function(plr)
	local animtracks = plr.Character.Humanoid:GetPlayingAnimationTracks()
	local char = plr.Character
	if char:FindFirstChild("ForceField") then
		local TweenService = game:GetService("TweenService")
		local TweenInfoX = TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.In)
		local TweenProperties = {
			Scale = Vector3.new(0.5, 0.5, 0.5)
		}
		local Tween = TweenService:Create(char.ForceField.Mesh, TweenInfoX, TweenProperties)
		Tween:Play()
		wait(1)
		char:FindFirstChild("ForceField"):Destroy()
	end
	if game.Workspace.ForceField.Playing == true then
		game.Workspace.ForceField.Playing = false
	end
	for i,v in pairs(animtracks) do
		if v.Name == "ForceField" then
			v:Stop()
		end
	end
end)

Local Script in StarterCharacterScripts:

local plr = game.Players.LocalPlayer
local debounce = false
local shieldup = false

game:GetService("UserInputService").InputBegan:Connect(function(p1, p2)
	if p2 then
		return;
	end
	if p1.KeyCode == Enum.KeyCode.Q then
		shieldup = true
		if not debounce then
			debounce = true
			game.Lighting.RemoteEvents.JeanEventsX.ForceFieldStart:FireServer()
		end
	end
end)

game:GetService("UserInputService").InputEnded:Connect(function(p1, p2)
	if p2 then
		return;
	end
	if p1.KeyCode == Enum.KeyCode.Q and shieldup == true then
		game.Lighting.RemoteEvents.JeanEventsX.ForceFieldEnd:FireServer()
		wait(4)
		debounce = false
	end
end)

Video of what happens:

Screenshot of the shield setup:

image

1 Like

ForceField.Position = Character.HumanoidRootPart.Position

Try ForceField.CFrame = Character.HumanoidRootPart.CFrame

1 Like

Maybe try making the part can collide off?

thank you! i don’t understand why i didnt try that in the first place lol