hi, im having a problem by destroying the weld when i press t and the ball is already attached to the right arm. I maked this script for the throw in the tool. it works when i press the second time “t” but after i can’t catch it anymore and it gives me in the output this:
i tried using this:
local RS = game:GetService("ReplicatedStorage")
local Throw = RS:WaitForChild("Throw")
Throw.OnServerEvent:Connect(function(player)
local Character = player.Character or player.CharacterAdded:Wait()
Character:FindFirstChild("Right Arm"):WaitForChild("Weld"):Destroy()
end)
i would appreciate if u can help me
It depends on how you created the weld. If it’s name isnt exactly “Weld” you will get this error, or if there is no weld at all.
So do
Throw.OnServerEvent:Connect(function(player)
local Character = player.Character or player.CharacterAdded:Wait()
if Character:FindFirstChild("Right Arm"):WaitForChild("Weld") then
Character:FindFirstChild("Right Arm"):WaitForChild("Weld"):Destroy()
end
end)
So it will attempt to destroy the weld only if there is a weld at all. And make sure that it is actually named “Weld”, if not, change the script accordingly to search it by its name
i created the well right here:
local RS = game:GetService("ReplicatedStorage")
local AttachE = RS:WaitForChild("AttachE")
AttachE.OnServerEvent:Connect(function(player)
local Character = player.Character or player.CharacterAdded:Wait()
local RL = Character:FindFirstChild("Right Arm")
local function Attach(Part)
local brick = Character:findFirstChild("Right Arm")
local weld = Instance.new("Weld")
weld.Part0 = brick
weld.Part1 = Part
weld.C0 = CFrame.new(0,0,0)
weld.C1 = CFrame.new(0.3,0.3,0.8)
weld.Parent = brick
end
RL.Touched:Connect(function(hit)
if hit.Locked == true or hit.Anchored == true then return end
if hit.Name == "Ball" or hit.Name == "ball" then
if script.Parent.Ball.Value == 0 then
script.Parent.Ball.Value = 1
local ball = hit
if (RL.Position - ball.Position).magnitude then
Attach(ball)
end
end
end
end)
end)