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

How can I weld a mesh handle to a player's hand through ServerScript?

#Introduction

I'm creating a script where when a player presses E next to a tree, it will play a chop animation, freeze them, and weld an axe to their hand.

However, I don't know how I would do that.

#Script

Oh yeah, here's my script for reference.

local player = game.Players.PlayerAdded:Wait()
local character = player.Character or player.CharacterAdded:Wait()
while not character.Parent do
	character.AncestryChanged:Wait()
end
local Humanoid = character:WaitForChild('Humanoid')
local HRP = character:WaitForChild('HumanoidRootPart')

local mouse = player:GetMouse()

local Anim = Instance.new("Animation",script.Parent)
Anim.Name = "ChopAnim"
Anim.AnimationId = 'rbxassetid://3027147369'
local Animation = Humanoid:LoadAnimation(Anim)
local Part = script.Parent

print(Tool.Name)
game.ReplicatedStorage.PressedE.OnServerEvent:Connect(function()
	if (HRP.Position - Part.Position).magnitude < 4.5 then
		if player.PlayerGui:WaitForChild('Job').Value == "Lumberjack" then
			--weld over here
		end
	end
end)

#Conclusion / Problem

Note: The axe is in the ReplicatedStorage and the PressedE RemoteEvent is in ReplicatedStorage.

Can someone teach me how I would weld a tool to the player's right hand? Thanks if you reply!

Regards, Sensei_Developer

1 answer

local weld = Instance.new(“Weld”)
weld.Part0 = -- It’s your hand
weld.Part1 = Tool.Handle
weld.C0 = weld.Part0.CFrame
weld.C1 = weld.Part1.CFrame * CFrame.new(1,1,1) * CFrame.Angles(math.rad(1),math.rad(1),math.rad(1)) -- Adjust this CFrame.new and CFrame.Angles. Keep the math.rad

2 comments

0

Okay, I'll try it.

0

Nope. Doesn't work...

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