Pick up & Drop Box System Not Working

I scripted a system where you could drop and pick up boxes for one of my old games, and it worked fine. Now I’m inserting it into another Workspace, and it’s not working at all. I’m getting no outputs, nothing. I tested it earlier today (in my old game) and it worked fine too. I inserted the exact same models, scripts, everything, and I’m not missing ANYTHING. Here’s the code:

local runService = game:GetService("RunService")
local AnimationClipProviderService = game:GetService("AnimationClipProvider")

local Player = game.Players.LocalPlayer
local PlayerGui = Player.PlayerGui

local Pickupable = game.Workspace:WaitForChild("Pickupable")
local carryAnimation = script:WaitForChild("CarryAnimation")

local carryDistZ = -2.7
local carryDistY = -0.5

local carryAnimTrack = nil

for _,v in pairs(Pickupable:GetChildren()) do
	if v:IsA("Part") then
		local clickDetector = v:WaitForChild("ClickDetector")
		local Gui = v:WaitForChild("BillboardGui")
		
		clickDetector.MouseClick:Connect(function(plr)
			print("Carry System MouseClickEvent: " .. plr.Name)
			
			local character = game.Workspace:FindFirstChild(plr.Name)
			local humanoid = character:WaitForChild("Humanoid")
			
			if not carryAnimTrack then
				runService.Stepped:Wait()
				carryAnimTrack = humanoid:LoadAnimation(carryAnimation)
			end
			
			if not v:FindFirstChildWhichIsA("WeldConstraint") and not plr:FindFirstChild("Carry") then
				v.Anchored = false
				
				local carryVal = Instance.new("BoolValue", plr)
				carryVal.Name = "Carry"
				
				local weldConstraint = Instance.new("WeldConstraint", v)
				v.CanCollide = false
				v.CFrame = character.HumanoidRootPart.CFrame * CFrame.new(0, carryDistY, carryDistZ)
				weldConstraint.Name = "WeldConstraint"
				weldConstraint.Part0 = v
				weldConstraint.Par1 = character.HumanoidRootPart
				Gui.Enabled = false
				carryAnimTrack:Play()
			elseif v:FindFirstChildWhichIsA("WeldConstraint") then
				carryAnimTrack:Stop()
				v:FindFirstChildWhichIsA("WeldConstraint"):Destroy()
				plr:FindFirstChild("Carry"):Destroy()
				v.CanCollide = true
				carryAnimTrack = nil
				Gui.Enabled = true
			end
		end)
	end
end
1 Like

check if any of the childs have what they are waiting for

I’ve already done that, and they do have the childs they are waiting for.

the script seems fine, I can’t think of any other solution other than to use proximity instead of clickdetectors

it could maybe be something wrong with the click detector’s properties or if it’s archivable

I may have fondu a solution to my issue. I’m using a loop and it’s possible it’s causing it to bug out. After talking about it with one of my mates, they remade my entire system and used RemoteEvents, and it worked. Thank you for your help Vergil, I hope you have a great day! :grin:

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.