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

why my ores dont spawn on locations??

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()

1 comment

0

please fix your code formatting, when editing your text, click lua and put your code in between those lines

1 answer

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! :)

1 comment

0

Not working

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