Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

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

3 comments

0

Is there a way like that for models or groups of parts?

0

Weld all the parts in the model to a central part (WeldConstraint would be useful), then weld that to the player.

0

Ok

This discussion is preserved as it was. New answers, comments, and votes are closed.