Script help pcall

script

its normal script ,

errormessage

this error

Why are you wrapping a pcall on a variable initialization

Maybe trying using waitforchild?

Why are you wrapping it in a pcall? Also, from the error the call doesn’t look like the problem. Are you sure that “Weld” is a child of the part.

local part = script.Parent

local weld= part:WaitForChild("Weld")

weld:Destroy()

cause some “part” don’t have weld.

Then wait for the part to have a weld

Is “Weld” a child of the part?

yes “weld” child of the part cause i used pcall

Is that the whole script because it looks cut off in the screenshot

That is not what pcall does. Pcall calls a function in a protected environment, and should be avoided unless you are doing something where errors are expected and can’t be fixed such as HTTP functions.

1 Like

The whole screen shot will not be different if I send it

Are you inserting a weld into the part or is the weld already there, check in game and see if a weld is in the part your referencing in the script

some “part” have weld that’s why there is an error

Alright then you just figured out your own problem congrats

already i know the error but i don’t know how to fix it

I don’t really understand your error, is “Weld” not a child of the part?

weld

weld is in some part. it mean “Weld” child of the parts

And the script is a child of one of the parts that has a weld in it?

yeah “weld” in some part. I think you understand

local part = script.Parent
local weld = part:FindFirstChildOfClass("Weld") -- find a weld

if weld then -- check if it exists
    weld:Destroy() -- get rid of it
end

You don’t need pcall here
Also, what is the script’s parent? is it copy and pasted into the parts or…