.Touched does not fire for this brick (and all other bricks made this way)

Alright so, lemme start from the beggining.
Around 3 days ago, I started making a Cutscene Plugin. And it went just fine! Everything worked, and I released the plugin, however, something just… broke. I’m not sure what happened. Here is the problem:
The cutscenes start when you touch a brick. They use the .Touched event. But they just don’t work. Like, at all. Not even a TouchInterest or TouchTransmitter gets created. Also, the bricks do have their CanTouch property on, yes.

The weird thing is, they worked perfectly 3 hours ago. I didn’t make any changes to the script, it just broke by itself, somehow. I guess I could use a loop with the new OverlapParams thing, but I’d much rather do it with events.

If you are wondering, I took the plugin down. I’ll make it public again after this gets fixed.

4 Likes

Did you check the output for errors?

1 Like

Yes, nothing gets printed. The connection is fine. The event just never fires.

1 Like

Hmm, have you tried cloning the script and putting it in a new part?

1 Like

It’s not a script in each brick, it’s 1 script in ServerScriptService that goes through all cutscenes and connects the function to their start brick.

Here’s the script, if it helps anything.

local http = game:GetService("HttpService")
local players = game:GetService("Players")
local event = game:GetService("ReplicatedStorage"):WaitForChild("SteelCutsceneHandler")
local coolDownName = "CutscenePlaying"

local function ModelIsInPart(model: Model, part: BasePart)
	for _, touching in ipairs(workspace:GetPartBoundsInBox(part.CFrame, part.Size * 1.25, OverlapParams.new())) do
		if touching:IsDescendantOf(model) then
			return true
		end
	end
	return false
end

for _, model in ipairs(workspace:GetDescendants()) do
	if model:IsA("Model") then
		local length = model:FindFirstChild("FrameLengthData")

		if length then
			local frames = {}

			for _, child in ipairs(model:GetChildren()) do
				if tonumber(child.Name) then
					child:ClearAllChildren()
					child.Transparency = 1
					child.CanCollide = false
					table.insert(frames, child)
				end
			end

			local frameData = {
				frameSpeed = http:JSONDecode(length.Value),
				tweenStyle = Enum.EasingStyle[model.TweenStyle.Value],
				skippable = model.Skippable.Value,
				walkable = model.Walkable.Value,
				fov = model.FOV.Value
			}

			for _, frame in ipairs(frames) do
				frameData[frame.Name] = frame
			end

			local start = model:WaitForChild("Start")
			start:ClearAllChildren()

			start.Touched:Connect(function(hit)
				local char = hit.Parent
				if not char then return end

				local player = players:GetPlayerFromCharacter(char)

				if (player and char.Humanoid:GetState().Name ~= "Dead" and not player:FindFirstChild(coolDownName)) then
					local function TagPlayer(otherPlayer: Player)
						local playerHasFinishedCutscene

						local coolDownTag = Instance.new("ObjectValue")
						coolDownTag.Name = coolDownName
						coolDownTag.Parent = otherPlayer

						while not playerHasFinishedCutscene do
							local finishedPlayer = event.OnServerEvent:Wait() -- This would only fail if 2 players played the same cutscene (or a cutscene with the same length) at the EXACT same time.
							if finishedPlayer == otherPlayer then
								playerHasFinishedCutscene = true
							end
						end

						if otherPlayer.Character then
							repeat task.wait() until not ModelIsInPart(otherPlayer.Character, start)
						end	
						coolDownTag:Destroy()
						coolDownTag = nil
					end

					if model["1PlayerExclusive"].Value then
						task.spawn(TagPlayer, player)
						event:FireClient(player, frameData)
					else
						for _, otherPlayer in ipairs(players:GetPlayers()) do
							task.spawn(TagPlayer, otherPlayer)
							event:FireClient(otherPlayer, frameData) -- If we're already gonna iterate over all players, then why use FireAllClients?
						end
					end
				end
			end)
		end
	end
end
2 Likes

it maybe because it’s always touching something, so to fix it you need to detect if it’s a player thtat’s touching it.

edit: or you already did

2 Likes

That’s not the problem. The problem is that the event never fires. Even if I connect it in another place, it just does not fire for the starter bricks.

1 Like

can you try adding a print so you can see if the touch event actually works?

2 Likes

I have done this already, as i’ve said, it does not fire (print anything in this case)
It might also help that a touchtransmitter or touchinterest is never created.

so the touch event just does not work?

1 Like

Have you playtest the game and went into server and seen if the server script is still there?

1 Like

Yes. The touched event is the problem here. It’s not doing anything. Connection works fine, no errors in the output, it just never fires or makes touchtransmitters/interests

1 Like

I somehow forgot, I’m going to test that, give me a few minutes.

1 Like

Alright, sorry for making this thread before testing it in an actual game. It worked fine. Still begs the question however, what happened, and why? I even reseted Studio multiple times. Hmm.

2 Likes

Studio, doesn’t have access to some apis so maybe its that

1 Like

I’m pretty sure .Touched isn’t an API, always worked for me even offline. Anyways, thanks man!

3 Likes