I’m trying to implement this into my tool’s script:
but the weld doesnt work in game. I’m not sure whats causing this as its in a server script.:
local Enabled = true
script.Parent.OnServerEvent:Connect(function(player, action, var)
if Enabled == false then return end
local char = player.Character
if action == 'Attack' then
Enabled = false
local Anim = script.Swing1
local PlayAnim = char.Humanoid:LoadAnimation(Anim)
PlayAnim:Play()
wait(1)
Enabled = true
for i, v in pairs (workspace.Children()) do
if v:FindFirstChild('HumanoidRootPart') and v:FindFirstChild('Humanoid') then
if v ~= char then
if (v.HumanoidRootPart.Position - char.HumanoidRootPart.Position) .Magnitude < 5 then
v.Humanoid:TakeDamage(20)
end
end
end
end
end
end)
local m6d
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
tool = char:FindFirstChildWhichIsA("Tool")
tool.Equipped:Connect(function()
local a:Weld = char:FindFirstChild("Right Arm"):WaitForChild("RightGrip")
m6d = Instance.new("Motor6D")
m6d.Parent = char:FindFirstChild("Right Arm")
m6d.Name = "RightGrip"
m6d.Part0 = a.Part0
m6d.Part1 = a.Part1
m6d.C0 = a.C0
m6d.C1 = a.C1
a:Destroy()
end)
tool.Unequipped:Connect(function()
m6d:Destroy()
end)