Basically, I’m making a spawner and I want the items that spawn to be oriented a specific way, but it just doesn’t work. I’m using PivotTo:
because it allows the hitbox inside the part to also be teleported. I know there is a way by making the spawner rotate a specific way first before spawning, but that just sounds like spaghetti code waiting to happen. Is there a way to solve this?
local module = game:GetService("ServerStorage"):WaitForChild("WeaponList")
local modulescript = require(module)
local itemtable = modulescript.RandomizeWeapon(chances)
local spawnlist = modulescript.WeaponList(List)
local handles = game.ServerStorage:WaitForChild("HandleList")
local item
local spawned = false
local debugmode = false
debugmode = true
local function randomzier(randomitem)
local counter = 0
local base = math.random(1,100)
for i,v in pairs(itemtable) do
counter = counter + v
if base <= counter then
item = spawnlist[i]
local tool = handles:FindFirstChild(item)
if not tool then
warn("Error 402: Handle '".. item.. "' can't be found")
return
end
if spawned == false then
-- enable value debug if you want print statement below to run
if debugmode == true then
print("Success! Handle '".. item .. "' has been successfully spawned, rarity: ".. itemtable[i] .. "%")
end
local clone = tool:Clone()
if item == "FryingPan" then
script.Parent.Orientation = Vector3.new(0,0,90)
end
clone:PivotTo(script.Parent.CFrame)
task.wait()
clone.Parent = script.Parent
script.Parent.Orientation = Vector3.new(0,0,0)
spawned = true
end
end
end
end
while true do
randomzier()
task.wait(2)
if script.Parent:FindFirstChildOfClass("Part") or script.Parent:FindFirstChildOfClass("UnionOperation") or script.Parent:FindFirstChildOfClass("Model") or script.Parent:FindFirstChildOfClass("MeshPart") then
else
spawned = false
end
end