Selective culling system seems to not see event, event existent in area its supposed to be in

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)
1 Like

Otherwise, try this on the server script and local script

local ReplicatedStorage = game:GetService(“ReplicatedStorage”)
local Event = ReplicatedStorage:WaitForChild(“InteriorSpawn”)

`

3 Likes

Added to all the scripts, I am not seeing any change.

here is the map, its sporatic, works sometimes, other times it doesnt.

1 Like

I don’t see in your local script that InteriorSpawn:FireServer(). Maybe you forgot?

2 Likes

Try adding a print-statement before and after LP.CharacterAdded:Wait() it may be an issue with the characteradded event triggering before the script reaches this point.

2 Likes

The local script only listens, the server side is what fires the event.

2 Likes


That is exactly what is going on, so whats the remedy?

1 Like

Maybe it works if you do

local Character = LP.CharacterAdded:Wait()
local HumanPart = Character:WaitForChild(“Humanoid”)

1 Like

In my experience, adding the local prefix to definitions not inside secluded blocks doesnt impact things much. I honestly think because im waiting for the humanoid on a local script anyway, I can probably forgo the waiting for the character. Ill have to play it by hear.

1 Like

Simply check if the Character is already loaded in:

local Character = LP.Character or LP.CharacterAdded:Wait()
3 Likes

That did the trick thank you for the suggestion.

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