it’s a long script but anyways
local OrbSystem = {}
OrbSystem.__index = OrbSystem
OrbSystem.Orbs = {}
OrbSystem.PlayersWithOrb = {}
function OrbSystem:SpawnOrbs(Mode, Bombs)
local Tiles = game.Workspace.Map.Tiles:GetChildren()
for i, v in pairs(OrbSystem.Orbs) do
if table.find(Tiles, v) then
table.remove(Tiles, table.find(Tiles, v))
end
end
--for i, v in pairs(Bombs) do
-- if table.find(Tiles, v) then
-- table.remove(Tiles, table.find(Tiles, v))
-- end
--end
game.Workspace.Orbs:ClearAllChildren()
for i, v in pairs(game:GetService("ServerStorage"):WaitForChild("Orbs"):GetChildren()) do
local Min
local Max
if v.Name == "DoubleJumpOrb" then
Min = Mode:GetAttribute("DoubleJumpOrbsMin")
Max = Mode:GetAttribute("DoubleJumpOrbMax")
elseif v.Name == "SwiftnessOrb" then
Min = Mode:GetAttribute("SwiftnessOrbsMin")
Max = Mode:GetAttribute("SwiftnessOrbsMax")
elseif v.Name == "DashOrb" then
Min = Mode:GetAttribute("DashOrbsMin")
Max = Mode:GetAttribute("DashOrbsMax")
elseif v.Name == "LowGravityOrb" then
Min = Mode:GetAttribute("LowGravityOrbsMin") -- Error in this line
Max = Mode:GetAttribute("LowGravityOrbsMax")
end
if Max ~= 0 then
for i = math.random(Min, Max), 1, -1 do
if #Tiles >= 1 then
local RndTile = Tiles[math.random(1, #Tiles)].Hitbox
table.insert(OrbSystem.SpawnOrbs(), RndTile.Parent)
local Clone = v:Clone()
Clone.Parent = game.Workspace.Orbs
Clone:MoveTo(RndTile.Position + Vector3.new(0, RndTile.Size.Y / 2 + Clone.Hitbox.Size.Y / 2 - 0.8, 0))
for i, v in pairs(Clone:GetChildren()) do
if v:IsA("Part") or v:IsA("MeshPart") then
v.CanTouch = true
end
end
end
end
end
end
for i, v in pairs(game.Workspace.Orbs:GetChildren()) do
v.Hitbox.Touched:Connect(function(v1)
if v1.Parent:FindFirstChild("Humanoid") ~= nil then
if not table.find(OrbSystem.PlayersWithOrb, v1.Parent.Name) and table.find(BombSystem.PlayersWithBomb, v1.Parent.Name) then
table.insert(OrbSystem.PlayersWithOrb, v1.Parent.Name)
task.defer(function()
task.wait(v:GetAttribute("AbilityTime") + 0.5)
table.remove(OrbSystem.PlayersWithOrb, table.find(OrbSystem.PlayersWithOrb, v1.Parent.Name))
end)
if v.Name == "DoubleJumpOrb" then
RemoteEvent:FireClient(game.Players:FindFirstChild(v1.Parent.Name), "Ability", v.Name, v:GetAttribute("AbilityTime"), v:GetAttribute("TimeToRefil"))
elseif v.Name == "SwiftnessOrb" then
RemoteEvent:FireClient(game.Players:FindFirstChild(v1.Parent.Name), "Ability", v.Name, v:GetAttribute("AbilityTime"), v:GetAttribute("SpeedMultiply"), v:GetAttribute("MultiplyWhenShpinting"))
elseif v.Name == "DashOrb" then
RemoteEvent:FireClient(game.Players:FindFirstChild(v1.Parent.Name), "Ability", v.Name, v:GetAttribute("AbilityTime"), v:GetAttribute("TimeToRefil"), v:GetAttribute("DashAnimation"))
elseif v.Name == "LowGravityOrb" then
RemoteEvent:FireClient(game.Players:FindFirstChild(v1.Parent.Name), "Ability", v.Name, v:GetAttribute("AbilityTime"), v:GetAttribute("LowGrav_FallAnim"))
end
for a, b in pairs(v:GetChildren()) do
if b:IsA("Part") or b:IsA("MeshPart") then
game:GetService("TweenService"):Create(b, TweenInfo.new(0.2, Enum.EasingStyle.Quint, Enum.EasingDirection.In, 0), {Size = Vector3.new(0, 0, 0)}):Play()
end
end
task.wait(0.2)
v:Destroy()
end
end
end)
end
end
return OrbSystem