Hello! I have made a flower-generating script. After the flower is generated there is an ObjectValue inside of it whose value is supposed to be set to the tile the flower was generated.
I have tried browsing through the Developer Forum but I haven’t been able to find a solution for this.
Here is the code:
local tiles = greenHouse:GetChildren()
local chosenTile = tiles[math.random(1,#tiles)]
if chosenTile:IsA("Part") and chosenTile.Taken.Value == false then
chosenTile.Taken.Value = true
local playerSeeds = seeds:GetChildren()
local seed = playerSeeds[math.random(1,#playerSeeds)]
local seedVal = seed.Value
if seedVal > 0 then
local isFlower = plantModule["Biomes"][seed.Biome.Value][seed.Name]
if isFlower ~= nil then
local newFlower = isFlower[2]:Clone()
newFlower.Parent = workspace
newFlower:SetPrimaryPartCFrame(chosenTile.CFrame)
chosenTile.Taken.Value = true
local tile = Instance.new("ObjectValue", newFlower)
tile.Value = chosenTile -- **Here is where the value is supposed to be changed**
tile.Name = "Tile"
seed.Value -= 1
for _, v in pairs(newFlower:GetDescendants()) do
if v:IsA("Part") or v:IsA("MeshPart") then
v.Position = v.Position - Vector3.new(0,10,0)
end
end
for _, v in pairs(newFlower:GetDescendants()) do
if v:IsA("Part") or v:IsA("MeshPart") then
game.TweenService:Create(v, tweeninfo, {Position = v.Position + Vector3.new(0,13,0)}):Play()
end
end
end
end
end
Thank you in advance,
Sxr1pted