A part in replicated storage deletes itself somehow

So there is a part required for the game to work IN REPLICATED STORAGE. when i run the game nothing happens, but when i click a specific button in game that starts the gameplay, the part gets destroyed. I checked for a long time what script was deleting it, but could not find anything. There was a script in the part, and when i disabled it, the part stopped disappearing. I do not see any relation between the rep storage version and the script, because it adresses only the cloned part from what i can understand, so how is disabling this script preventing the part from disappearing and what is making it disappear in the first place? I also tried changing the script name and it didnt help. I NEED ANSWERS!

local function gen()
	local rooms = {"BigRoom","BigRoom","BigRoom","BigRoom","NoRoom"}
	local roomnew = game.ReplicatedStorage.rooms[rooms[math.random(1,#rooms)]]:Clone()
	roomnew.Parent = workspace.Floor1.rooms
	roomnew:PivotTo(script.Parent:GetPivot())
	script.Parent:Destroy()
end
script.Parent.Touched:Connect(function(mHit)
	if mHit.Name == "Hit" then
		gen()
	end
end)
1 Like

Hi! In my case script works good, Part cloned, touched, destroyed. Part in replicated storage still in there.
So i think problem in script which cloning part, can you please show it us?

1 Like

Where is this script located? If it’s directy in the room model you are calling script.Parent:Destroy() on line 6.

Try print("Name = ", script.Parent.Name) between lines 5 and 6 to see if it names the original model or the roomnew model.

Okay I found the problem and it was not in the script, it just started a domino effect in which another script removed the part from replicated storage, so disabling the script prevented the domino effect but also made the initial diagnosis wrong. I fixed it all yay

1 Like

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