WeldConstraint/BallSockets teleporting objects to 0, 0, 0 when welded. (please help)

Im trying to make a VR pickup system however when trying to create welds or ballsockets my arms and the object teleport to 0, 0, 0

DISCLAIMER
Im filming on pc so i have to use my camera to control the arms so excuse the camera angles.

Local VR Script


--PLAYER--
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Camera = game.Workspace.CurrentCamera
local starterGui = game:GetService("StarterGui")


--SERVICES--
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local VRService = game:GetService("VRService")
local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")

--REMOTES--
local ArmRemote = ReplicatedStorage.VREvents.ArmRemote
local PickUpRemote = ReplicatedStorage.VREvents.PickUp
local ArmStartRemote = ReplicatedStorage.VREvents.ArmStart


--if VRService.VREnabled == true then



	--VALUES--
	local CurrentArm = nil

	starterGui:SetCore("VRLaserPointerMode", 0)
	starterGui:SetCore("VREnableControllerModels", false)
	Camera.HeadScale = 1

	ArmStartRemote:FireServer()


	ArmStartRemote.OnClientEvent:Connect(function()
		local LeftHand = Character:WaitForChild("LeftHand")
		local RightHand = Character:WaitForChild("RightHand")
		
		RunService.RenderStepped:Connect(function()
			--Camera.CFrame = CFrame.new(Character.HumanoidRootPart.Position)+Vector3.new(0,3,0)
			
			LeftHandTrack = VRService:GetUserCFrame(Enum.UserCFrame.LeftHand)
			LeftHand.AlignOrientation.CFrame = Camera.CFrame * LeftHandTrack
			LeftHand.AlignPosition.Position = Camera.CFrame * LeftHandTrack.Position
			
			RightHandTrack = VRService:GetUserCFrame(Enum.UserCFrame.RightHand)
			RightHand.AlignOrientation.CFrame = Camera.CFrame * RightHandTrack
			RightHand.AlignPosition.Position = Camera.CFrame * RightHandTrack.Position
			
		end)

		local function onInputBegan(input, _gameProcessed)
			if input.KeyCode == Enum.KeyCode.ButtonR1 or input.KeyCode == Enum.KeyCode.R  then
				
				CurrentArm = "right"
				
				local ArmPosition = Camera.CFrame * RightHandTrack
				
				PickUpRemote:FireServer(ArmPosition, CurrentArm)
			elseif input.KeyCode == Enum.KeyCode.ButtonL1 then
				CurrentArm = "left"
				
				local ArmPosition = Camera.CFrame * LeftHandTrack
				
				PickUpRemote:FireServer(ArmPosition, CurrentArm)
			end
		end

		UserInputService.InputBegan:Connect(onInputBegan)

		while task.wait(1) do
			ArmRemote:FireServer()
		end
	end)
	
--end


Server Script
--SERVICES--
local ReplicatedStorage = game:GetService("ReplicatedStorage")

--REMOTES--
local ArmRemote = ReplicatedStorage.VREvents.ArmRemote
local PickUpRemote = ReplicatedStorage.VREvents.PickUp
local ArmStartRemote = ReplicatedStorage.VREvents.ArmStart

--OBJECTS--
local HitBox = ReplicatedStorage.PickHitBox
local TextLabel = workspace.OutputBox.SurfaceGui.TextLabel

ArmStartRemote.OnServerEvent:Connect(function(player, LeftHand, RightHand)
	local LeftHand = ReplicatedStorage.LeftHand:Clone()
	LeftHand.Parent = player.Character
	local RightHand = ReplicatedStorage.RightHand:Clone()
	RightHand.Parent = player.Character
	ArmStartRemote:FireClient(player)
	
	RightHand:SetNetworkOwner(player)
	LeftHand:SetNetworkOwner(player)
end)


PickUpRemote.OnServerEvent:Connect(function(player, ArmPosition, CurrentArm)

	local HitBoxClone = HitBox:Clone()
	HitBoxClone.Parent = player.Character
	HitBoxClone.CFrame = ArmPosition

	local PartsInBox = workspace:GetPartsInPart(HitBoxClone)
	
	local LeftArm = player.Character:WaitForChild("LeftHand")
	local RightArm = player.Character:WaitForChild("RightHand")

	for i,v in pairs(PartsInBox) do
		TextLabel.Text = v.Name
		if v:HasTag("Handle") then
			
			v:SetNetworkOwner(player)
			
			print("Welding!")
			
			local Weld = Instance.new("WeldConstraint")

			if CurrentArm == "right" then
				Weld.Parent = RightArm
				Weld.Part0 = RightArm
				
				Weld.Part1 = v
				
			elseif CurrentArm == "left" then
				Weld.Parent = LeftArm
				Weld.Part0 = LeftArm
				
				Weld.Part1 = v


				
			end

		elseif v:HasTag("Grip") then
			
			v:SetNetworkOwner(player)

			local GripWeld = Instance.new("BallSocketConstraint")
			
			
			local ObjectAt = Instance.new("Attachment")
			ObjectAt.Parent = v
			ObjectAt.WorldPosition = ArmPosition.Position

			if CurrentArm == "right" then
				GripWeld.Parent = RightArm
				GripWeld.Attachment0 = RightArm.GrabAt
				GripWeld.Attachment1 = ObjectAt
				
				
				task.wait()
				
				player.Character:FindFirstChild("RightHand").CFrame = ArmPosition
				
				v.CanCollide = false
				v.Massless = true
				
				task.wait()
				v.CanCollide = true
				v.Massless = false
				

			elseif CurrentArm == "left" then
				
				GripWeld.Parent = LeftArm
				GripWeld.Attachment0 = LeftArm.GrabAt

				GripWeld.Attachment1 = ObjectAt
				
				
				
				task.wait()
				
				player.Character:FindFirstChild("LeftHand").CFrame = ArmPosition
				
				v.CanCollide = false
				v.Massless = true
				
				task.wait()
				
				v.CanCollide = true
				v.Massless = false



			end
 		
		end
		
	end
end)

Video of whats happening (i need to use camera to move arms cause im on PC)

any help would be appreaciated

1 Like