[FIXED]I have a problem when cloning a map with ServerStorage

Has been fixed by someone in a roblox dev discord server
Hi i’ve been trying to fix this bug on my game for the past 10 days and i’ve only found out what was the problem right now, basically, for my game, a map from ServerStorage is cloned, then placed on workspace on a specific posistion. Inside this map there’s a door code system, and the code answer is stored as an IntValue inside the display that displays the code when clicked.

The problem is, when it’s a cloned map, with this code,:

local remote = game.ReplicatedStorage.RemoteEvents.EnableKeycode
local TweenService = game:GetService("TweenService")
local door = script.Parent.Parent
local doorCharniere = door.PrimaryPart
local doorTweenInfo = TweenInfo.new()
local doorCharTween = TweenService:Create(doorCharniere, doorTweenInfo, {
	CFrame = doorCharniere.CFrame * CFrame.Angles(0, math.rad(120), 0)

	local CodeValue = door.Parent.Parent.PC.Screen.Code
	local GUI = player.PlayerGui.KeycodeGUI
	local fix = GUI.Frame.Frame.CodeSee
	if tonumber(text) == CodeValue.Value then
			fix.Text = "Correct code"
		    fix.TextColor3 = Color3.fromRGB(0, 200, 0)
			fix.Text = ""
			fix.TextColor3 = Color3.fromRGB(255, 255, 255)
			script.Parent.Prompt.Enabled = false
			fix.Text = "Incorrect Code"
			fix.TextColor3 = Color3.fromRGB(200, 0, 0)
			fix.Text = ""
			fix.TextColor3 = Color3.fromRGB(255, 255, 255)

it will always say that the answer is false even though it is correct .

But when it’s not a cloned map (copy paste on workspace), and I do the same thing, this time the script works normally (displays “Correct code” when code is correct and “Incorrect code” when it’s incorrect.

I don’t understand why this happens but i’m almost sure that it’s not my scripts problem.
Any help is appreciated!

Version that doesn’t have problems(copy paste of the game but without cloning script and other things): debug.rbxl (126.8 KB)

Version that has problems : Atmos [Indev] - Roblox

Main game script ( clones the map) :

local Players = game:GetService("Players")
local intermisionLegnth = 30
local choosingMapLength = 15
local InRound = game.ReplicatedStorage.InGame
local LobbySpawn = game.Workspace.Lobby.LobbySpawn
local Status = game.ReplicatedStorage.Status
local ChoosingMap = game.ReplicatedStorage.ChoosingMap
local RoundSpawn = game.Workspace.Lobby.LobbySpawn
local minutes = 5
local seconds = 0
local mapChosen = game.ServerStorage["_Colorful Warehouse"]

while true do
		for i = intermisionLegnth, 0, -1 do
			InRound.Value = false
			Status.Value = "Intermission ("..i..")"
		ChoosingMap.Value = true
		for i = choosingMapLength, 0, -1 do
			Status.Value = "Choosing map... ("..i..")"
		InRound.Value = true
		ChoosingMap.Value = false
		local pos = {Vector3.new(0,0,0),Vector3.new(0,0,200),Vector3.new(0,0,400),Vector3.new(0,0,600),Vector3.new(0,0,800),Vector3.new(0,0,1000),Vector3.new(0,0,1200),Vector3.new(0,0,1400),Vector3.new(0,0,1600),Vector3.new(0,0,1800),Vector3.new(0,0,2000),Vector3.new(0,0,2200),Vector3.new(0,0,2400),Vector3.new(0,0,2600),Vector3.new(0,0,2800),Vector3.new(0,0,3000),Vector3.new(0,0,3200),Vector3.new(0,0,3400),Vector3.new(0,0,3600),Vector3.new(0,0,3800)}
		for i, player in pairs(Players:GetPlayers())do
			local clone = mapChosen:Clone()	
			clone.Parent = game.Workspace.CurrentlyLoaded
	    	print("Initiated map"..mapChosen.Name..i)
		local char = player.Character
			char.HumanoidRootPart.CFrame = clone.Spawn.CFrame
		if seconds <= 0 then
			minutes = minutes - 1
			seconds = 59
			seconds = seconds - 1
		if seconds <= 9  then
			Status.Value = tostring(minutes)..":0"..tostring(seconds)
			Status.Value = tostring(minutes)..":"..tostring(seconds)
		until minutes <= 0 and seconds <= 0
		minutes = 5
	    seconds = 0
	for i, player in pairs(Players:GetPlayers()) do
		local char = player.Character
		char.Humanoid.BreakJointsOnDeath = false
		char.Humanoid.Health = 0
	for i, player in pairs(Players:GetPlayers()) do
		local char = player.Character
		char.HumanoidRootPart.CFrame = LobbySpawn.CFrame

Also I noticed that the door tweening is also buggy when it’s a cloned map


should be:

local CodeValue = door.Parent.Parent.PC.Screen.Code.Value

Unsure though, show the hierachy of the models if you can.


Nevermind, I just fully read your script and you used CodeValue.Value, my bad.

1 Like

The hierarchy of the models is here

Version that doesn’t have problems(copy paste of the game but without cloning script and other things): debug.rbxl (126.8 KB)

You can just screenshot the model and it’s children in workspace, you know.

1 Like

ok but it’s kinda long


Does anyone have an idea ? Maybe it’s too hard to solve oof

Are you using a local script. If yes then use a server script. If that doesn’t work, then put the map in ReplicatedStorage | Roblox Creator Documentation.

1 Like

Thanks for the advide, but is there another way ? I wanna make sure that people can’t steal my assets by putting the assets in the server side only, but if it works i’ll make sure to mark it as solution!

No, I don’t think there’s another way unfortunately.

1 Like

ok i’ll try it right now then thanks

I tried but sadly it still has the same problem that is so strange :frowning:
i’m 99% sure that it’s not the scripts fault because it works normally when I copy paste it via studio

Don’t use a local script. Use a server script.

1 Like

It’s all server scripts in the map, I think it might be something else

is there a script that changes the codeValue ?

1 Like

No there’s only a script that generates the code and sets the value as the code as soon as the cloned map is generated in workspace

try instead of “CodeValue = door.Parent.Parent.PC.Screen.Code” just type “CodeValue = 100”, this will give us a better idea of what the problem is

1 Like

Yea but door.Parent.Parent.PC.Screen.Code is a random ganerated integer between 1000 and 9999.
I don’t think there’s a problem with the script since it works perfectly when I just put it in workspace by hand

i’mma try to set it at a specific integer just to be sure

can you send me the script that generates the random code ?

You forgot to clone it. Do local mapChosen = game.ServerStorage["_Colorful Warehouse"]