Function setting CharacterAutoLoads to false doesn't set CharacterAutoLoads to false

I’m trying to write a script with a function triggered by a bindable event that disables and enables CharacterAutoLoads but whenever the function is run, it remains enabled. The script is a server script inside ServerScriptService

I have no idea what I’m doing wrong.

local ReplicatedStorage = game:GetService(“ReplicatedStorage”)
local Players = game:GetService(“Players”)
local autoLoad = Players.CharacterAutoLoads
local roundStart = ReplicatedStorage.RoundStart
local roundEnd = ReplicatedStorage.RoundEnd

roundStart.Event:Connect(function()
autoLoad = false
end)

roundEnd.Event:Connect(function()
autoLoad = true
end)

Try this:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local roundStart = ReplicatedStorage.RoundStart
local roundEnd = ReplicatedStorage.RoundEnd

roundStart.Event:Connect(function()
Players.CharacterAutoLoads = false
end)

roundEnd.Event:Connect(function()
Players.CharacterAutoLoads = true
end)

I think instead of changing the property that the variable represents, you’re just changing the variable is the problem.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.