#module script not saving

20 messages · Page 1 of 1 (latest)

earnest pollen
#

module.Teams isnt saving playerTeam after running module.tpTeam, and when i reference it in module.killTeam, playerteam is blank, but teamtruck isnt

the player part of module.Teams isnt blank when printing on line 43 in module.tpTeam, but when i call it in another server script, the player part is gone

#
local module = {} 
module.Teams = {}

local repStor = game:GetService('ReplicatedStorage')
local truckFolder = repStor.Trucks

module.tpPlayer = function(player, part)
    player.Character:MoveTo(part.CFrame.Position)
end

module.ToggleConstraints = function(part, toggle)
    if #part:GetChildren() > 0 then
        for i, v in pairs(part:GetChildren()) do
            module.ToggleConstraints(v, toggle)
        end
    else
        if part.Name == 'WheelConstraint' or part.Name == 'SteeringConstraint' then
            part.Enabled = toggle
        end
    end
end

module.tpTeam = function(team, location, truck)
    local cTruck = truckFolder[truck]:Clone()
    cTruck.Name = 'Truck'
    cTruck.Parent = game.Workspace.PlayerTrucks
    cTruck:SetPrimaryPartCFrame(workspace.SpawnLocations[location].CFrame)
    
    team['Driver'].Character.Humanoid.JumpPower = 0
    team['Steerer'].Character.Humanoid.JumpPower = 0
    
    module.tpPlayer(team['Driver'], cTruck.SeatGo)
    cTruck.SeatGo:Sit(team['Driver'].Character.Humanoid)
    module.tpPlayer(team['Steerer'], cTruck.SeatSteer)
    cTruck.SeatSteer:Sit(team['Steerer'].Character.Humanoid)
    
    team['Driver'].Character.Parent = cTruck
    team['Steerer'].Character.Parent = cTruck
    
    
    
    table.insert(module.Teams, {playerTeam = team, teamTruck = cTruck})
    print(module.Teams)
end

module.killTeam = function(part)
    local truck
    print(module.Teams)
    if part.Parent.Name == 'Truck' then
        truck = part.Parent 
    else
        truck = part.Parent.Parent
    end
    for i, v in pairs(module.Teams) do
        print(module.Teams)
        if v.teamTruck == truck then
            v.playerTeam['Driver'].Character.Humanoid.Health = 0
            v.playerTeam['Steerer'].Character.Humanoid.Health = 0
            truck:Destroy()
        end
    end

    
end

return module
elder sorrel
#

So what does it print on team tp and what on killteam?

earnest pollen
#

@elder sorrel

elder sorrel
#

You only run it once?

earnest pollen
#

wat

elder sorrel
#

You only run tpteam once?

earnest pollen
#

yeah

#

whenn i assign it like this it saves it

unique dune
#

does the table go through any other function between tpTeam and killTeam?

earnest pollen
#

im printing it in another server script, but i dont think that affects it

elder sorrel
earnest pollen
#

ye

#

idk why it doenst save team but saves team[...]

elder sorrel
#

Maybe something with inserting a table into a table idk

unique dune
#

it seems like your reference 'team' may be getting overwritten somehow somewhere

#

thats the only reason I can think of at least

#

breakpoints are great for things like this