Objects not Spawning in set Place

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I am trying to spawn objects from Server Storage into workspace.

  2. What is the issue? Include screenshots / videos if possible!
    The issue is a banana that has been welded by a little part (the things that are welder are 2 meshes that make the banana)

image
image

Other object spawn perfectly but this banana does not want to

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

I’ve Tried looking over the other forums but I have not found
any promising solutions

Code :

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ServerStorage = game:GetService("ServerStorage")

local FallingObjectsFolder = ServerStorage:FindFirstChild("FallingObjects") -- Folder storing object models
local SpawnArea = workspace.SpawnZone -- Part above the mountain where objects spawn
local GroundLevel = workspace.GroundZone.Position.Y -- Despawn when objects reach this Y level

while true do
	wait(math.random(1, 3)) -- Random delay for objects to fall

	local objects = FallingObjectsFolder:GetChildren()
	if #objects > 0 then
		local randomObject = objects[math.random(1, #objects)]:Clone()

		-- Random spawn position above the climb area
		randomObject.Position = Vector3.new(
			SpawnArea.Position.X + math.random(-SpawnArea.Size.X/20, SpawnArea.Size.X/20), 
			SpawnArea.Position.Y, 
			SpawnArea.Position.Z + math.random(-SpawnArea.Size.Z/20, SpawnArea.Size.Z/20)
		)

		-- Enable physics
		randomObject.Parent = workspace
		randomObject.Anchored = false
		randomObject.Velocity = Vector3.new(0, -50, 0) -- Makes objects fall fast

		-- Despawn objects when they reach ground level
		game:GetService("Debris"):AddItem(randomObject, 20)-- Removes object after 5 sec
		if randomObject.CFrame.Y < GroundLevel then randomObject:Destroy() end
	end
end

could try using PivotTo()

local newPosition = Vector3.new(
	SpawnArea.Position.X + math.random(-SpawnArea.Size.X/20, SpawnArea.Size.X/20), 
	SpawnArea.Position.Y, 
	SpawnArea.Position.Z + math.random(-SpawnArea.Size.Z/20, SpawnArea.Size.Z/20)
)

randomObject:PivotTo(CFrame.new(newPosition))
1 Like

Yeah that’s correct, I completely forgot about using Pivot.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.