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

Setting SpawnLocation to specific area not working?

Asked by 6 years ago

Ok. This time, it seems illogical, as if rbx lua is wrong (for real.)

So i am trying to spawn people where they last left off, and for some odd reason, it chooses random areas to spawn, despite the fact that i tell it to look for a spawn location, INSIDE that instance, instead, the script takes it's own route and looks in a completely different instance. This is done by changing the RespawnLocation property of a Player

--//Services
local Players = game:GetService('Players')
local RS = game:GetService('ReplicatedStorage')
local ss = game:GetService('ServerStorage')

--//Events
local LoadCharacter = RS:WaitForChild('LoadCharacter')
local LoadGame = RS:WaitForChild('LoadGame')
local StartBeginningCutscene = RS:WaitForChild('BeginningCutscene')

--//Functions
local function LoadData(client)
    local Data = client:WaitForChild('Data')
    local MaxHealth = Data:WaitForChild('MaxHealth')
    local Health = Data:WaitForChild('HealthLeft')

    client.Character.Humanoid.MaxHealth = MaxHealth.Value
    client.Character.Humanoid.Health = Health.Value
end

LoadGame.OnServerEvent:connect(function(client)
    local Data = client:WaitForChild('Data')
    local Health = Data:WaitForChild('HealthLeft')
    local MaxHealth = Data:WaitForChild('MaxHealth')
    local LastLeftOff = Data:WaitForChild('LastLeftOff')

    if LastLeftOff.Value ~= 'New File' then
        local AreaLeftOff = ss:FindFirstChild(LastLeftOff.Value, true)
        AreaLeftOff:Clone().Parent = workspace
        client.RespawnLocation = AreaLeftOff:FindFirstChildWhichIsA('SpawnLocation', true)
        wait(3)
        client:LoadCharacter()
        LoadCharacter:FireClient(client)
        LoadData(client)
    else
        LastLeftOff.Value = 'Vati Spring'
        local AreaLeftOff = ss:FindFirstChild(LastLeftOff.Value, true)
        AreaLeftOff:FindFirstAncestorOfClass('Folder'):Clone().Parent = workspace
        client.RespawnLocation = AreaLeftOff:FindFirstChildWhichIsA('SpawnLocation', true)
        wait(3)
        client:LoadCharacter()
        LoadCharacter:FireClient(client)
        LoadData(client)
        client.Character:WaitForChild('AbleToPerform').Value = true
        StartBeginningCutscene:Fire(client)

    end
end)


It is set to 'NewFile' yet it spawns randomly. I check the wiki, and it can be set on either server or client, so... What is happening here?

1 answer

Log in to vote
0
Answered by 6 years ago

Have you tried using Vector3 instead?

Ad

Answer this question