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

why my ores dont spawn on locations??

Asked by 3 years ago
Edited 3 years ago

script:

local rockLocations = game.Workspace.RockLocations:GetChildren()
local numLocations = #rockLocations

for place = 1, numLocations - 1 do
    local rockClone = rock:Clone()
    rockClone.Parent = script.Parent
    rockClone.Position = rockLocations[place].Position
    rockLocations[place].Free.Value = false
end

rock:Destroy()
0
please fix your code formatting, when editing your text, click lua and put your code in between those lines MOREHOURSOFFUN 104 — 3y

1 answer

Log in to vote
0
Answered by
TGazza 1336 Moderation Voter
3 years ago

Try this:

local rock = script.Parent.Rock:Clone()
local rockLocations = game.Workspace.RockLocations:GetChildren() 
local numLocations = #rockLocations

rock:Destroy()

for place = 1, numLocations - 1 do 
    local rockClone = rock:Clone() 
    rockClone.Parent = script.Parent 
    rockClone.Position = rockLocations[place].Position 
    rockLocations[place].Free.Value = false 
end

all I've done is cloned the reference rock and used that clone for your rockClone variable. It looked like the code was spawning the rocks at your locations but then deleting them right after, So cloning the reference part makes a fresh/stand-alone copy of the reference part.

Hope this helps! :)

0
Not working moneyislands1 51 — 3y
Ad

Answer this question