How can I weld this can to the players r6 hand?

Hello, I have a coca cola can here and would like to weld it to their hand when ever they press e here is my code I do not know where to start or how to do this. If you could help me that would very appreciated!

local uis = game:GetService(“UserInputService”)
local player = game.Players.LocalPlayer
local character = player.Character
local cocaCola = game.ReplicatedStorage:WaitForChild(“CocaColaCan”)

uis.InputBegan:Connect(function(input, gameProccessedEvent)
if input.KeyCode == Enum.KeyCode.L then
	if cocaCola then
		print("coca cola")
		character.HumanoidRootPart.Anchored = true
		local cocalColaNew = cocaCola:Clone()
		cocalColaNew.Parent = workspace
		
		
		
	end
end
end)
1 Like

You can put it in a Tool. After that, put it in StarterPack instead of trying to weld it to the player’s hand.

I think you should not anchor the HumanoidRootPart either due to the fact that it will just freeze the player in position. Then, you can also just do cocalColaNew.Position = character.LeftArm (or right depends on you). After that, you can do + Vector3.new(0,2,0) and mess around with it to get it in the hand.

1 Like

Sorry I forgot to remove the anchor it was for my reset script and I know I needed to anchor the humanoid root part to stop it from moving. And thanks I’ll try this!

But I want to make it like a tool but I dont want it to be in their inventory.

Try looking at UserInputService and Welder.

Also Enum.KeyCode.L should be Enum.KeyCode.E

Yeah haha im changing that right now I just duplicated my other script and im re-adjusting it.

How can I now make the arm extended like it was a tool do I just do some kind of animation?

You can make an animation that puts the arm out, and play it when pressing E. Then, when unequipping, just stop the animation.

Make sure to set the animation priority to Action by the way!! :warning:

I just remembered this, but you can add a WeldConstraint from the CokeCan to the players arm.

Example:

local WC = Instance.new(“WeldConstraint”)
WC.Parent = character.LeftArm
WC.Part0 = character.LeftArm
WC.Part1 = cocalColaNew

I did this, but what is this priority action?

haha thanks I knew how to do it but I for some reason thinking I had to replace some of the animations in the player for some reason then I relised I was just being stupid. lol

You wanted the player to hold the drink, correct? Whenever you open the Animation Editor for a rig and put the arm up to hold the drink, the 3 dots will appear. If you hover over them you should see “Set Animation Priority”. You then click on Action so that the player can walk around and have the drink in his/her hand with their arm up, resembling a tool.

ahhh okay I use moon animator but ill see if moon animator can do this as well but thank you I did not know about this priority thing. Thanks!

You’re welcome, Zombie! Glad I could be of assistance.