ContextActionService:BindAction can only be called from a local script

MainItems:WaitForChild("MainDoor").Touched:Connect(function(Hit)
 // code here
end)

You don’t have this line:
MainItems:WaitForChild("OwnerDoor", 1):WaitForChild("MainDoor", 1).Touched:Connect(function(hit)

which line do i paste it on?
im just curios.

Instead of the MainItems:WaitForChild() line. Make sure it’s only one line what you paste. Also, quick note, I made it so that if it doesn’t find the item in one second, the code doesn’t run.

i dont understand, do i delete the MainItems:WaitForChild() line then paste it in?

1 Like

Yes. That should work. If you don’t want the function to not run if it doesnt find the instance, type the line like this:

MainItems:WaitForChild("OwnerDoor"):WaitForChild("MainDoor").Touched:Connect(function(hit)
ONLY do that if you want to see if the instance doesnt exist. If it doesn’t, you will see an error: "infinite yield possible on [v:WaitForChild()].

It came up again, I just didnt notice it,
image

Also came up with this error
image

Is it a server or local script? Where is it located?

I put it in scs

image

You should use starterplayerscripts rather, like i mentioned.

i put it in startercharacterscripts, what do you mean?
like remove the folder and only the main script?

The startercharacter scripts get cloned in the players character which is a descendant of workspace. And you know what that means, right?

Also where did you declare the MainItems variable? As it’s most likely the error here.

i don’t know sadly.
i do very poor in coding, yet i get enjoyment out of it.

I think this is it.

Change TycoonModel:FindFirstChild("MainItems") to TycoonModel:WaitForChild("MainItems"). If it says infinite yield in the output then do TycoonModel:WaitForChild("MainItems", 1) and check the TycoonModel variable for the same thing. Go into the explorer and check if there’s already the models that you need. It seems like as all the things you need don’t land where you need them.

now it says

Check the TycoonModel for same thing.

wdym?
i don’t really understand