Skip to content

Commit

Permalink
fix(SplitScreenMod): Asynchronously accessing variables is not allowed
Browse files Browse the repository at this point in the history
This fixes "attempt to index a nil value (global 'NewController')".
  • Loading branch information
UE4SS committed Dec 27, 2024
1 parent 1244004 commit 062fb28
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions assets/Mods/SplitScreenMod/Scripts/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,14 @@ local function CreatePlayer()
print(string.format("GameplayStatics: %s\n", GetGameplayStatics():GetFullName()))
ExecuteInGameThread(function()
NewController = GetGameplayStatics():CreatePlayer(PlayerControllerTable[1], #PlayerControllerTable, true)

if NewController:IsValid() then
table.insert(PlayerControllerTable, NewController)
print(string.format("Player %s created.\n", #PlayerControllerTable))
else
print("Player could not be created.\n")
end
end)
if NewController:IsValid() then
table.insert(PlayerControllerTable, NewController)
print(string.format("Player %s created.\n", #PlayerControllerTable))
else
print("Player could not be created.\n")
end

end

Expand Down Expand Up @@ -92,13 +93,13 @@ function TeleportPlayers()
DidTeleport = true
end
end
end)

if DidTeleport then
print("Players teleport to Player 1.\n")
else
print("No players could be teleported\n")
end
if DidTeleport then
print("Players teleport to Player 1.\n")
else
print("No players could be teleported\n")
end
end)
end


Expand Down

0 comments on commit 062fb28

Please sign in to comment.