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:

01local TreasureChest = game.ServerStorage:FindFirstChild("TreasureChestBuriedInSand")
02local newVector3 = Vector3.new(math.random(0,512),0,math.random(0,512))
03local newCFrame = CFrame.new(newVector3)
04 
05local function SpawnChest()
06    TreasureChest:Clone()
07    TreasureChest:Clone() CFrame = newCFrame
08    TreasureChest.Parent = game.Workspace
09end
10 
11while true do
12    SpawnChest()
13    print("chest spawned")
14    wait(5)
15end
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

01local TreasureChest = game.ServerStorage:FindFirstChild("TreasureChestBuriedInSand")
02local newVector3 = Vector3.new(math.random(0,512),5,math.random(0,512))
03local newCFrame = CFrame.new(newVector3)
04 
05local function SpawnChest()
06    lcoal treasureChestClone = TreasureChest:Clone()
07    treasureChestClone.CFrame = newCFrame
08    TreasureChest.Parent = game.Workspace
09end
10 
11while true do
12    SpawnChest()
13    print("chest spawned")
14    wait(5)
15end

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

Ad

Answer this question