Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Is there any way to make a object you can hold, without making it a tool?

Asked by 3 years ago
Edited 3 years ago

I've seen in some games, where you can hold something but it isn't a tool. I don't understand how, could somebody explain it to me?

1 answer

Log in to vote
0
Answered by 3 years ago

Yes. You just need to create a Weld instance. Of course, you will have to manage this weld and player input manually.

See this example code below (placed inside a part in the workspace)

local picked_up = false;

script.Parent.Touched:connect(function(hit)
    if (picked_up) then return end;
    if (game.Players:GetPlayerFromCharacter(hit.Parent) == nil) then return end;
    picked_up = true;
    script.Parent.Anchored = false;

    local r_hand = hit.Parent:FindFirstChild("RightHand");
    local weld = Instance.new("Weld", r_hand);
    weld.Part0 = r_hand;
    weld.Part1 = script.Parent;
    weld.C0 = CFrame.new();
    weld.C1 = CFrame.new(0,r_hand.Size.Y,r_hand.Size.Z);

end);

Video

0
Is there a way like that for models or groups of parts? awesomespeed101 6 — 3y
0
Weld all the parts in the model to a central part (WeldConstraint would be useful), then weld that to the player. R1ceNice 20 — 3y
0
Ok awesomespeed101 6 — 3y
Ad

Answer this question