Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 4 years ago

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
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 :) muataz1234 -2 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

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.

Ad

Answer this question