Basically I am welding the box when the proximity prompt is triggered. The problem is that there is a weird glitching happening.
External MediaThis is the code (moduleScript, I am just requiring the script for each box.)
local module = {}
-- This script is for grabbing.
function module.AddProximityAndConnect(part)
local block = part
local Parent = part
local proximityPrompt = Instance.new("ProximityPrompt")
proximityPrompt.Parent = Parent
local collectionService = game:GetService("CollectionService")
proximityPrompt.RequiresLineOfSight = false
proximityPrompt.Triggered:Connect(function(player : Player)
part:SetAttribute("CanGridLayout", false)
local weld = Instance.new("Weld")
local char = player.Character
local torso = char:WaitForChild("UpperTorso")
weld.Parent = block
weld.Part0 = block
weld.Part1 = torso
block.CFrame = torso.CFrame
local stackTable = workspace.BoxFolder[player.UserId].carrying:GetChildren()
local offset = 0
for i, blockIterate : BasePart in stackTable do
local add = blockIterate.Size.Y
offset += add
end
block.Position = block.Position + torso.CFrame.LookVector + Vector3.new(0, (offset+(block.Size.Y/2)), 0) + (block.CFrame.LookVector * block.Size.Z/2)
weld.Name = "BlockWeld"
block.ProximityPrompt.MaxActivationDistance = 0
block.CanCollide = false
block.Parent = workspace.BoxFolder[player.UserId].carrying
block.Massless = true
end)
end
return module
I am not sure why this is happening. I tried making the box massless which didn’t contribute at all. I read some post about setting rootPriority to -1 which also didn’t help.
Thanks in advance!