I’m not too sure for certain if this is a scripting issue but I’ll go with it.
So I’m making a Five Nights at Freddy’s game that has a Custom Night in it where you can select who is enabled and how difficult they are. I have that part all done for now, but there’s something up with the importing of characters from ReplicatedStorage.
Essentially, the client sends a table with each characters name and their difficulty. The server then goes through the table and if they character has a difficulty higher than 1, clones a template from ReplicatedStorage and puts it into a workspace folder.
The problem is, when the character gets put into the workspace.NPCs folder, all their custom components just disappear. They’re still there, toggling to server view shows all the parts are visible and in the explorer, but on the client they are nonexistant. The explorer shows they are gone. The problem is that there is a dummy of the character that HASN’T been imported but is exactly the same, and that Is visible to the client. So it’s not that the meshes don’t load, as they show up for the dummy.
Even weirder is that, beforehand, when I hadn’t built my custom night UI, the script was that the player joins, a character is imported for them to surviva against. But now, this new system just messes it up and I don’t know why as it is pretty much the same script. I disabled all scripts in the character and they don’t change it.
Client script (part that sends to server):
local function getCharInfo()
local ntbl = {}
local characters = script.Parent.Characters:GetChildren()
for _, char in pairs(characters) do
if char:IsA('Frame') and char:FindFirstChild('CurrentDifficulty') ~= nil then
ntbl[#ntbl + 1] = {char.Name, char.CurrentDifficulty.Value}
print(ntbl)
end
end
return ntbl
end
script.Parent.StartButton.MouseButton1Click:Connect(function()
events.BeginNight:FireServer(getCharInfo())
script.Parent.Visible = false
end)
Client script (part that clones all characters to workspace):
local events = game.ReplicatedStorage.Events
local nightSetupEvent = events.BeginNight
nightSetupEvent.OnServerEvent:Connect(function(plr, setup)
-- Scan the table for all characters
workspace.NPCs:ClearAllChildren()
for _, char in pairs(setup) do
if char[2] ~= 0 then -- 0 = not enabled
print(char[1] .. ' is enabled this night')
character = game.ReplicatedStorage.NPC:FindFirstChild(char[1])
if character then
print('found char')
npc = character:Clone()
npc.Parent = workspace.NPCs
npc:MakeJoints()
if npc:FindFirstChild('PlayerToChase') ~= nil then
npc.PlayerToChase.Value = plr.Name
npc.HumanoidRootPart.CFrame = workspace.Endoskeleton1Spawn.CFrame + Vector3.new(0, 2, 0)
end
end
end
end
end)
Here is the layout of the “Endoskeleton1”, which is my current testing character:
Disabling all of the scripts inside did nothing. No scripts destroy or change anything to do with the parts inside the character. The only part that shows up is the Hitbox part, meaning all my enemies are floating transparent boxes.
This issue occurs in the live client too, so it’s something with my game.
I have looked this up and did find a similar issue but that issue was a chance thing and this happens 100% of the time.
If I need to attach a place file, let me know and I’ll do that.
If any other info is required I will do my best to find it too, just let me know as well.
Sorry for such a long post, hope you can help me out here.