Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Orbit Script Will Insert The Planet Into Workspace But Will Not Make The Planet Orbit The Sun?

Asked by
LuaDLL 253 Moderation Voter
6 years ago

The Error Is When I Do table.insert()

local module = {}

--{{ Variables
local Host = script.Parent
local Angle = Host.Angle.Value
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Planets = ReplicatedStorage.Planets
local Speeds = {}
local Distances = {}
local PlanetsT = {}
local Rotations = {}
--  Earth.CFrame = Host.CFrame - CFrame.fromEulerAnglesXYZ(Angle,i * Speeds.Earth, 0) * Vector3.new(0, 0, Distances.Earth)

function module.Orbit(PlanetName,Speed,Distance)
    local Planet = Planets.Planet:Clone()
    Planet.Parent = game.Workspace
    Planet.Name = PlanetName
    table.insert(PlanetsT,Planet.Name) 
    table.insert(Speeds,Planet.Name,Speed) -- Errors here
    table.insert(Distances,Planet.Name,Distance) -- Errors here
    table.insert(Rotations,0)
    local Planett = game.Workspace[PlanetName]
    Planett.CFrame = Host.CFrame - CFrame.fromEulerAnglesXYZ(Angle,Rotations[Planett.Name] * Speeds[Planett.Name], 0) * Vector3.new(0, 0, Distances[Planett.Name])
end

return module

Script That Requires The Module:

local Sun = game.Workspace.Sun
local OrbitM = require(Sun.OrbitModule)

game.Players.PlayerAdded:Connect(function(plr)
    plr.Chatted:Connect(function(msg)
        if string.sub(msg,1,9) == "newplanet" then
            OrbitM.Orbit(string.sub(msg,10,99999),0.007,math.random(25,5000))
        end
    end)
end)

Answer this question