Hello, so I have this script down below
local floorNumber = script.Parent.Parent:GetAttribute("FloorNumber")
local tablets = game:GetService("ServerStorage").floorTablets
local delete = false
local newTablet = nil
script.Parent.Touched:Connect(function()
local tabletNumberGot = 1
local new = script.Parent.Parent:Clone()
new.Name = "Flight Of Stairs "..floorNumber + 1
new:SetAttribute("FloorNumber", floorNumber + 1)
new.Parent = workspace.Staircase
new:MoveTo(Vector3.new(script.Parent.Position.X,script.Parent.Position.Y + 18, script.Parent.Position.Z))
new.Circle.Transparency = 0
new.Circle.CanCollide = true
for i,v in new:GetChildren() do
if v.Name == "floorLeaderboardTrigger" then
v.floorLeaderboardTriggerScript.Enabled = true
end
if v.Name == "Stairs1" or v.Name == "Stairs2" then
v:PivotTo(v:GetPivot() * CFrame.Angles(0,math.rad(10),0))
end
end
repeat
local randomChance = math.random(1,15)
if randomChance == 1 then
tabletNumberGot += 1
end
until 5
for i,v in tablets:GetChildren() do
if string.find(v.Name, tabletNumberGot) then
newTablet = tablets["floorTablet"..tabletNumberGot]
end
end
local spawnTablet = newTablet:Clone()
spawnTablet.Parent = new
print(spawnTablet:GetPivot())
spawnTablet:PivotTo(spawnTablet:GetPivot() + Vector3.new(34, 18.6 + (36.95 * (floorNumber + 1)), 10))
for i,v in spawnTablet:GetDescendants() do
if v:IsA("Part") then
v.CanCollide = false
end
end
for i,v in new:GetChildren() do
if string.find(v.Name, "Tablet") then
if delete == true then
v:Destroy()
end
delete = true
end
end
script.Parent.Parent.Shadows:Destroy()
script.Parent:Destroy()
end)
It Basically spawn a new floor in an infinite staircase. The main problem is that it spawn the amount of tablets equal to a floor number. If it’s a floor 3, it spawn 3 tablets, floor 7, 7 tablets. If you need any screen shots i’ll send them. Thanks for helping!
edit: I changed the script to a new one, now i have a new problem, for some reason every new tablet goes slightly higher