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