I’m trying to make a pick up system, where you grab a box pick it up and hold it.
The only problem though, is that the box is way off from being normal:
(as seen here)
What would be the best approach to fix this?
(Server) Script:
local interact = script.Parent
local tweenservice = game:GetService("TweenService")
local newCharPos = script.Parent.Parent.Parent:WaitForChild("CharacterPos")
local rs = game:GetService("ReplicatedStorage")
local animFolder = rs.Animations
local grab = animFolder.Grab
local hold = animFolder.Holding
local function grabbed(player)
local holding = player:WaitForChild("isHolding")
local character = player.Character or player.CharacterAdded:Wait()
local human = character.Humanoid
local humRootPart = character.HumanoidRootPart
local grabAnim = human.Animator:LoadAnimation(grab)
local holdAnim = human.Animator:LoadAnimation(hold)
if holding.Value == false then
human.WalkSpeed = 0
humRootPart.CFrame = newCharPos.CFrame
task.wait(0.5)
grabAnim:Play()
task.wait(0.14)
local boxModel = script.Parent.Parent.Parent.Parent
boxModel.Parent = player.Character
local box = boxModel.Box
box.Union.Anchored = false
interact.Parent.Anchored = false
box.Union.CanCollide = false
box.Union.CFrame = player.Character.RightHand.CFrame * CFrame.Angles(-51.33, 5.536, -7.937) -- I was doing it manually here.
local weld = Instance.new("WeldConstraint", box)
weld.Part1 = box.Union
weld.Part0 = player.Character.RightHand
grabAnim.Stopped:Wait()
human.WalkSpeed = 16
holdAnim:Play()
holding.Value = true
interact.Enabled = false
end
end
interact.Triggered:Connect(grabbed)
Is there an animation with the hands while moving. If you’re going for a normal look i would say just make them hold it with both hands horizontally. If it is a tool as the guy above said, go with that.
To make it look like you are actually holding the box with your hand, you will need to make a weld between the box and the hand, and change the size of the box to be the exact size of your hand.
So, first, you will want to set the size of the box to be equal to the hand. This can be done by looking at the box in studio, and setting the size values to be the same as your hand. Then, you can copy the size values of the box and past them into your script: box.Size = Vector3.new(INSERT VALUES HERE)
And then to make the weld: local weld = Instance.new(“Weld”, box)
weld.Part0 = box.Union
weld.Part1 = player.Character.RightHand
I got it working,
I recommend instead of running the game, getting the hand size, copy and paste. Roblox has many different character packages, so I don’t think the hand size will all be the same. Instead do: