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

Whats wrong with the regen?

Asked by 9 years ago

I am using xLegox's 3.0 cart track, and there is one problem, it won't regen! Here is the script.

local cartModel = script.Parent.TrainCart:clone()

local spawnButton = script.Parent.SpawnButton
local origin = script.Parent.Origin

local buttonOffColor = BrickColor.new(1007)
local buttonOnColor = BrickColor.new(1020)


function enable(cart)
    cart.Parent = game.Workspace
    cart:MakeJoints()
    cart.DriveScript.Disabled = false
end

--returns: is the space to spawn the cart in free?
function isFree()
    local origincf = origin.CFrame
    local a = (origincf*CFrame.new(-3.5, 1, -5.5)).p 
    local b = (origincf*CFrame.new(3.5, 5, 5.5)).p
    local ax, ay, az = a.x, a.y, a.z
    local bx, by, bz = b.x, b.y, b.z
    if ax > bx then ax, bx = bx, ax end
    if ay > by then ay, by = by, ay end
    if az > bz then az, bz = bz, az end
    local list = game.Workspace:FindPartsInRegion3(Region3.new(Vector3.new(ax, ay, az), Vector3.new(bx, by, bz)))
    return #list == 0
end

--enable the current cart
enable(script.Parent.TrainCart)

do
    local debounce = false
    function doSpawn()
        if not debounce and isFree() then
            debounce = true
            enable(cartModel:clone())
            wait(0.1)
            debounce = false
        end
    end
end

--set up connections
spawnButton.Touched:connect(function(obj)
    local par = obj.Parent
    if par and par:FindFirstChild("Humanoid") then
        doSpawn()
    end
end)
spawnButton.ClickDetector.MouseClick:connect(doSpawn)
--spawnButton.DoSpawn.Receive = doSpawn --requires future updates

--show open state
while true do
    wait(0.1)
    if isFree() then
        spawnButton.BrickColor = buttonOnColor
        origin.Fire.Enabled = true
    else
        spawnButton.BrickColor = buttonOffColor
        origin.Fire.Enabled = false
    end
end

1
I have 2 questions; 1: what does the output say? 2: are all the names of the carts, buttons, and everything correct with the script? TigerCaptain 75 — 9y
0
The output says nothing, but I found something strange. On a different game the regen works fine. The only fiffrence between the two games is that one used to be a personal server? Does that affect it at all? collinman60 10 — 9y
0
personal servers should not change things from a regular game. use print() to figure out what functions are firing and what are not. heck, the script could be disabled, or something odd like that. TigerCaptain 75 — 9y

Answer this question