Skip to content

Commit

Permalink
Use RunContext for client script.
Browse files Browse the repository at this point in the history
  • Loading branch information
TheNexusAvenger committed Nov 23, 2024
1 parent 27a19c9 commit cd311e9
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 16 deletions.
5 changes: 5 additions & 0 deletions src/NexusVRCharacterModelClientLoader.meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"properties": {
"RunContext": "Client"
}
}
17 changes: 1 addition & 16 deletions src/init.luau
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,9 @@ local VERSION_COMMIT = "00000000"
--briefly, such as an unstable connection.
local REPLICATION_RATE_LIMIT = 35



local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local HttpService = game:GetService("HttpService")
local StarterPlayer = game:GetService("StarterPlayer")

local Settings = require(script:WaitForChild("State"):WaitForChild("Settings")).GetInstance()
local RateLimiter = require(script:WaitForChild("State"):WaitForChild("RateLimiter"))
Expand Down Expand Up @@ -81,19 +78,7 @@ function NexusVRCharacterModel.Load(self: NexusVRCharacterModel): ()
(require(ReplicatedStorage:WaitForChild("NexusVRCharacterModel"):WaitForChild("Util"):WaitForChild("Warnings")) :: any)()

--Set up the client scripts.
local NexusVRCharacterModelClientLoader = script:WaitForChild("NexusVRCharacterModelClientLoader")
for _, Player in Players:GetPlayers() do
task.spawn(function()
--Create and store a ScreenGui with the script.
--This prevents the script disappearing on respawn.
local ScreenGui = Instance.new("ScreenGui")
ScreenGui.ResetOnSpawn = false
ScreenGui.Name = "NexusVRCharacterModelClientLoader"
NexusVRCharacterModelClientLoader:Clone().Parent = ScreenGui
ScreenGui.Parent = Player:WaitForChild("PlayerGui")
end)
end
NexusVRCharacterModelClientLoader:Clone().Parent = StarterPlayer:WaitForChild("StarterPlayerScripts")
script:WaitForChild("NexusVRCharacterModelClientLoader").Parent = ReplicatedStorage

--Set up replication.
local ReadyPlayers = {}
Expand Down

0 comments on commit cd311e9

Please sign in to comment.