Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

I've tried to clone a Treasure chest but its not working!!?!?

my code is:

local TreasureChest = game.ServerStorage:FindFirstChild("TreasureChestBuriedInSand")
local newVector3 = Vector3.new(math.random(0,512),0,math.random(0,512))
local newCFrame = CFrame.new(newVector3)

local function SpawnChest()
	TreasureChest:Clone()
	TreasureChest:Clone() CFrame = newCFrame
	TreasureChest.Parent = game.Workspace
end

while true do
	SpawnChest()
	print("chest spawned")
	wait(5)
end

1 comment

0

thank you dead walker, heres some more info, TreasureChestBuriedInSand is a model in server storage, the script u helped me with is in server script service what u gave me gives me an error saying CFrame is not a valid member of Model "TreasureChestBuriedInSand" if u do not know why u can just leave this, thank you :)

1 answer

Your code has a few erros and you might want to move the Y up so its not in the baseplate

local TreasureChest = game.ServerStorage:FindFirstChild("TreasureChestBuriedInSand")
local newVector3 = Vector3.new(math.random(0,512),5,math.random(0,512))
local newCFrame = CFrame.new(newVector3)

local function SpawnChest()
    lcoal treasureChestClone = TreasureChest:Clone()
    treasureChestClone.CFrame = newCFrame
    TreasureChest.Parent = game.Workspace
end

while true do
    SpawnChest()
    print("chest spawned")
    wait(5)
end

If this didnt help please give me more info on the error messages if there are any.

This discussion is preserved as it was. New answers, comments, and votes are closed.