Hello, I’ve been working on a single-player game and am using a client-side approach to save server memory. Recently, I moved the ENTIRE map and GAME SYSTEMS to the client. However, I’m now encountering an issue where the controller script for doors has stopped functioning, even after changing it to a LocalScript.
local doorsFolder = script.Parent
local debounce = false
local debounceTime = 1.5
for _, door in ipairs(doorsFolder:GetChildren()) do
if door:IsA("Model") then
local openSound = door:FindFirstChild("door_open")
local closeSound = door:FindFirstChild("door_close")
local clickDetector = door:FindFirstChild("Click"):FindFirstChild("ClickDetector")
local KEY_FOUND = door:FindFirstChild("KeyFound")
local OPENED = door:FindFirstChild("Opened")
if openSound and closeSound and clickDetector and KEY_FOUND and OPENED then
clickDetector.MouseClick:Connect(function()
if debounce then
return
end
debounce = true
task.spawn(function()
if KEY_FOUND.Value then
clickDetector.MaxActivationDistance = 0
end
task.wait(debounceTime)
if not KEY_FOUND.Value then
clickDetector.MaxActivationDistance = 10
end
debounce = false
end)
if KEY_FOUND.Value then
if not OPENED.Value then
OPENED.Value = true
openSound:Play()
for i = 1, 18 do
door:SetPrimaryPartCFrame(door.PrimaryPart.CFrame * CFrame.Angles(0, math.rad(-5), 0))
task.wait(0.02)
end
end
else
local lock_sound = door:FindFirstChild("door_locked")
if lock_sound then
lock_sound:Play()
end
end
end)
end
end
end
This is how the model looks
Btw, the map is stored in ReplicatedStorage and cloned to workspace depending on the player’s level. Everything is on the client.