I have a game that uses culled interiors, and the script I use to spawn the interiors locally, seemingly is not working reliably even tho it has worked in the past. I cannot figure out why, its acting as if it cant see the event, even tho the script is active and the event present where it should be. I am getting no errors either, what perplexes me further is it seems to work sporatically, sometimes you can join and it functions other times it doesnt.
Local Script:
- Spy Building Company Interior Cull Script V2
--- Created: 2/10/2024
---- Original Programer: Sterling_ODeaghaidh(10283957)
------------------Global Definitions------------------
local Gamespace = game.Workspace
local Repstore = game.ReplicatedStorage
local Players = game:GetService("Players")
local LP = Players.LocalPlayer
-- --
LP.CharacterAdded:Wait()
-- --
HumanPart = LP.Character:WaitForChild("Humanoid")
local Event = Repstore.InteriorSpawn
local TweenService = game:GetService("TweenService")
------------------Variables---------------------------
PlayerInside = false
Debounce = false
CurrentInterior = nil
------------------Main Code---------------------------
-- game.ReplicatedStorage.Decorations.Parent = game.Workspace
Event.OnClientEvent:Connect(function(Interior,Sensor)
print(Interior,Sensor)
if Debounce == false then
Debounce = true
if Interior ~= "SoftenSound" then
if PlayerInside == false then
local InteriorCopy = Repstore:WaitForChild(Interior.Name):Clone()
PlayerInside = true
CurrentInterior = InteriorCopy
InteriorCopy.Parent = Gamespace.TempItems
----
for index, child in pairs(game.Workspace.WeatherSounds:GetChildren()) do
if child:IsA("Sound") then
child.Volume = .05
end
end
----
if Sensor ~= nil then
LP.Character:SetPrimaryPartCFrame(Sensor.In.CFrame)
end
else
PlayerInside = false
CurrentInterior:Destroy()
CurrentInterior = nil
----
for index, child in pairs(game.Workspace.WeatherSounds:GetChildren()) do
if child:IsA("Sound") then
if child.Name == "Wind" then
child.Volume = .3
else
child.Volume = .5
end
end
end
----
if Sensor ~= nil then
LP.Character:SetPrimaryPartCFrame(Sensor.Out.CFrame)
end
end
else
if PlayerInside == false then
PlayerInside = true
print(1)
for index, child in pairs(game.Workspace.WeatherSounds:GetChildren()) do
if child:IsA("Sound") then
local tweenInfo = TweenInfo.new(
1, -- Duration in seconds
Enum.EasingStyle.Linear, -- Easing style
Enum.EasingDirection.Out, -- Easing direction
0, -- Number of times to repeat
false, -- Reverses the tween on repeat
0 -- Delay time
)
local goal = {Volume = 0.05}
local volumeTween = TweenService:Create(child, tweenInfo, goal)
volumeTween:Play()
end
end
else
PlayerInside = false
print(2)
for index, child in pairs(game.Workspace.WeatherSounds:GetChildren()) do
if child:IsA("Sound") then
local goal = 0
----------------------------
if child.Name == "Wind" then
goal = {Volume = 0.3}
else
goal = {Volume = 0.5}
end
local tweenInfo = TweenInfo.new(
1, -- Duration in seconds
Enum.EasingStyle.Linear, -- Easing style
Enum.EasingDirection.Out, -- Easing direction
0, -- Number of times to repeat
false, -- Reverses the tween on repeat
0 -- Delay time
)
local volumeTween = TweenService:Create(child, tweenInfo, goal)
volumeTween:Play()
end
end
end
end
wait(.5)
Debounce = false
end
end)
HumanPart.Died:Connect(function()
PlayerInside = false
CurrentInterior = nil
Gamespace.TempItems:ClearAllChildren()
end)
Server side:
-- Selective Culling System
--- Created: 8/13/2021
--- Updated: 2/10/2024
---- By: Sterling_ODeaghaidh
------------Variables----------------------
Sensor = script.Parent
Building = Sensor.Inside.Value
-----------------------Begin Code----------
-----Setup
script.Parent.Transparency = 1
Sensor.In.Transparency = 1
Sensor.Out.Transparency = 1
-----Worky Bits
Sensor["City Hall"].Triggered:Connect(function(Player)
print("ping")
game.ReplicatedStorage.InteriorSpawn:FireClient(Player,Building,Sensor)
end)
game.ReplicatedStorage.InteriorSpawn.OnServerEvent:Connect(function(I,M)
if I == Building then
script.Parent["City Hall"].ActionText = M
end
end)