Interacting with morph type object's breaks script

i have a server side script that breaks when doing a attack

after debugging it happens when it interacts with a certine models

like morphs , items givers and chairs

is there a way i can make my charater ignore stuff like that

i dont have any debug info only from constent testing when ever i ran into the object when
in code attacking = true
the script crashs and stops taking input

another solution would be to make the script not crash
if so is there a way to make the script ignore-errors
or retry
there is no syntax errors in my code
its just that interacting with objects makes it crash
i use ids and status for every event
from id = 1 and attack id = 1
attacking = true
attacks are binded to keys along with froms
if id = 1 and key m was pressed then form id = 2
or function transform1
id = 3
this is not the code just a idea of how its setup

how to create script that makes the player ignore morphs and any interaction

you can ignore errors by doing

--all the dangerous code u want to run in the middle thats likely to error

the issue is i dont know where its erroring and my code used to be fd so it has a bunch of old functions

aka bad practice

you could just wrap it around ur entire code lolol or send a screenshot of ur code and ill see if i can see where it prolly needs to go , my likely guess is it will be wherever u are looping through the items hit and checknig them

ummm i said bad pratice before so
its about lets say 60k lines
tons of shortcuts

so basicly i put the pcall at the top

but i have functions in the code too will it break?

can u just send a few screenshot so i can get a feel for how ur code is made up

@S0MBRX sorry its been a wile so im need to get back into it
i have not used studio seense my last post in janary

yeah yeah so like in the functions change them from this sort of structure

local function LOL()
	if true then
		print("BLAH BLHA")

to this structure

local function LOL()
		if true then
			print("BLAH BLHA")

just do that to all ur functions

yahh about that

just do it to the function thats giving the error

when you run your code it will have the error in the output, click the red bit of the error and it should send u to the line of code where the error is happening

ohh its 4 functions that are doing it attack type functions
if that does not work is there a way to ignore morphs and stuff like that

this is what the start of a attack looks like

there is but it depends on how u are detecting them in the first place
raycasting, region3 provide filtering in their parameters

otherwise u just gotta do it using logic like:

if detectedPart:IsA(“MeshPart”) then

for that function do i need to loop it

while true do
if detectedPart:IsA(“MeshPart”) then

that doesnt really tell me much bout how it works but yeah just wrap the inside of that function in a pcall
see if it works yknow

ok il try that first
give me some time to setup the morphs

in that while loop context you would use break instead or set the condition of the loop to false

breaks (break a loop/ stop a loop)
return (returns from the function to the function calling point and can carry variables with it if set to )