#obby deletion not working
2 messages · Page 1 of 1 (latest)
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Workspace = game:GetService("Workspace")
local obbies = {
ReplicatedStorage:FindFirstChild("Obby1"),
ReplicatedStorage:FindFirstChild("Obby2"),
ReplicatedStorage:FindFirstChild("Obby3")
}
local obbyPositions = {
Vector3.new(-182.07, 6.523, -170.648),
Vector3.new(-182.07, 6.523, -170.648)
}
local function ChooseRandomPosition()
return obbyPositions[math.random(1, #obbyPositions)]
end
local function RemoveObby(obbyModel)
if obbyModel then
obbyModel:Destroy()
end
end
local function ChooseAndPlaceObby()
local selectedObby = obbies[math.random(1, #obbies)]
if selectedObby then
local clonedObby = selectedObby:Clone()
clonedObby.Parent = Workspace
-- Choose a random position for the obby
local randomPosition = ChooseRandomPosition()
clonedObby:SetPrimaryPartCFrame(CFrame.new(randomPosition))
end
end
local roundStartedValue = ReplicatedStorage:WaitForChild("InRound")
local roundEndedValue = ReplicatedStorage:WaitForChild("Status")
roundStartedValue.Changed:Connect(function()
local roundHasStarted = roundStartedValue.Value
if roundHasStarted then
ChooseAndPlaceObby()
else
RemoveObby()
end
end)