Script error issue


image
as you can see in the two above images, the error states that Tie S1 does not exist in an object, yet the script is not trying to recall that object.
the Script is present in “ML Switch B01-2T Crossover Right” and directs to Tie S1 via script.Parent, which is a common parent of the script and Tie S1
For WHATEVER reason, the script thinks it is trying to access “ML Switch B29 Parallel Left” despite the script only running script.Parent from “ML Switch B01-2T Crossover Right”

What the actual heck is going on?!

Could you post a screenshot of the hierarchy?

Yeah, just send a picture of the hierarchy, my brain is hurting trying to figure out what you meant lol.

1 Like

Tie S1 shares the same parent as the script
Script.Parent[“Tie S1”] should lead exactly to it…

My brain is breaking. The only way this would be possible is if the script is somehow re-parented before it reaches line 50.

What output do you get when you change line 50 and 51 to

print(script.Parent)
local SwitchSound1 = script.Parent['Tie S1'].SwitchSound

no scripts in this place change the parent of any object (I dont use free models or have other devs)
My brain is as broken as yours, It genuinely makes no sense!
I would report this as a platform bug but I don’t have access

and just to be sure, I did print the scripts parent, its the same as it is before play testing

Try WaitForChild

local SwitchSound1 = script.Parent:WaitForChild("Tie S1").SwitchSound

if it doesn’t work and as it is a BasePart, check that it is anchored, it may fall out of the world.

it is anchored, but I will try that, that seems like an obvious fix lol

I thought this too, but the script seems to have confused its own parent object. Check the output, it states Tie S1 is not a valid member of a different model the script isn’t parented to.

@BritishTrainspotting So when you printed the script’s parent on line 50, does it print ML Switch B01-2T Crossover Right?

it does print that yes, so I’m not sure what’s going on

Try restarting studio or Uninstalling studio then install it again.

Try to change the line to

local SwitchSound1 = workspace['ML Switch B01-2T Crossover Right']['Tie S1'].SwitchSound

Far from the cleanest code, but if that works, we can narrow down the issue

that wont fix the script issue…

it could be related, It happened to me once and I fixed it by that.

how would re-installing studio fix the issue with the script when I dont play test in studio? Even if I was play-testing in studio I dont see how that could remotely affect the processing of scripts

Could you share a file that experiences the same issue? That’d help everyone here diagnose the issue.

Could be because your studio is outdated But likely not if other scripts are working…
Try adding it in a pcall function

local Success, errorMessage = pcall(function()
	script.Parent:FindFirstChild("Tie S1"):FindFirstChild("SwitchSound") 
	
end)

if Success then
	print("Success")
end

I dont playtest in studio, and outdated studio would not affect a script not using new functions
Studio was recently updated too.

1 Like

I’d rather not share my game file especially as I am aware of bots stalking me on the devforums owned by banned users

Then please provide a minimal place file that contains the affected parts/scripts (in the correct hierarchy).

1 Like