Simple error that I can't understand

Let me know if you find the solution and check out my 2 ideas. I’ve had this issue sometimes and it’s extremely frustrating.

1 Like

I spawn NPCs all the time and this is never an issue for me.

Formatting shouldn’t have an impact.

1 Like

Okay, I’ll definitely check it out. I made you do the work, so I will definitely do it, thank you.

1 Like

It has to do with how the service/class singleton is being accessed.

local rs = game:GetService("ReplicatedStorage")
rs:WaitForChild("Ok")

is no different to

game:GetService("ReplicatedStorage"):WaitForChild("Ok")

as I’m aware, I may be wrong.

1 Like

image

Finally guys. It worked. Topaz, thanks for the work done, but unfortunately I didn’t use it due to the simplicity of the solution. Emskipo thank you for solving this problem.

2 Likes

In that specific case your correct. But using “game.ReplicatedStorage” is an incorrect method of accessing the ReplicatedStorage service.

You could think about it like this if anyone is confused why this makes a difference.

game.ReplicatedStorage - Is actually accessing the class definition of ReplicatedStorage.
You could probably access and use functions defined within that class definition and it may work.

game:GetService(“ReplicatedStorage”) - Is actually accessing an instance of the ReplicatedStorage class. That instance is what contains the unique contents placed into the replicated storage folder in a specific game.

If I had a class in my game “PlayerData” and each time a player joined the game I created an instance of that class for that specific player. Then only the instance created for that player would contain that player’s specific data. But the class definition would still contain all the functions and default properties that any instance might have. Hopefully that makes sense and clears up the why.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.