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 4 years ago
Edited 4 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 4 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)

01local picked_up = false;
02 
03script.Parent.Touched:connect(function(hit)
04    if (picked_up) then return end;
05    if (game.Players:GetPlayerFromCharacter(hit.Parent) == nil) then return end;
06    picked_up = true;
07    script.Parent.Anchored = false;
08 
09    local r_hand = hit.Parent:FindFirstChild("RightHand");
10    local weld = Instance.new("Weld", r_hand);
11    weld.Part0 = r_hand;
12    weld.Part1 = script.Parent;
13    weld.C0 = CFrame.new();
14    weld.C1 = CFrame.new(0,r_hand.Size.Y,r_hand.Size.Z);
15 
16end);

Video

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

Answer this question