Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Filtering Enabled Door Script not working?

Hi Im trying to create a filtering enabled door which turns for red to green, destroys its decal and its cancollide to false. The LocalScript works but the Script doesnt. It doesnt show any errors and it doesnt even show its printed word.

LocalScript (Placed in TextLabel under ScreenGUI under StarterGUI):

db = false
local hum = game.Workspace["Human Spawn"]
local text = script.Parent

function OnTouch(hum)
	if db == false then
		db = true
		text.Text = 35
		wait(1)
		text.Text = 34
		wait(1)
		text.Text = 33
		wait(1)
		text.Text = 32
		wait(1)
		text.Text = 31
		wait(1)
		text.Text = "Door will open in 30 seconds"
		wait(1)
		text.Text = 29
		wait(1)
		text.Text = 28
		wait(1)
		text.Text = 27
		wait(1)
		text.Text = 26
		wait(1)
		text.Text = 25
		wait(1)
		text.Text = 24
		wait(1)
		text.Text = 23
		wait(1)
		text.Text = 22
		wait(1)
		text.Text = 21
		wait(1)
		text.Text = 20
		wait(1)
		text.Text = 19
		wait(1)
		text.Text = 18
		wait(1)
		text.Text = 17
		wait(1)
		text.Text = 16
		wait(1)
		text.Text = 15
		wait(1)
		text.Text = 14
		wait(1)
		text.Text = 13
		wait(1)
		text.Text = 12
		wait(1)
		text.Text = 11
		wait(1)
		text.Text = "Door will open in 10 seconds"
		wait(1)
		text.Text = 9
		wait(1)
		text.Text = 8
		wait(1)
		text.Text = 7
		wait(1)
		text.Text = 6
		wait(1)
		text.Text = "Door will open in 5 seconds"
		wait(1)
		text.Text = "Door will open in 4 seconds"
		wait(1)
		text.Text = "Door will open in 3 seconds"
		wait(1)
		text.Text = "Door will open in 2 seconds"
		wait(1)
		text.Text = "Door will open in 1 seconds"
		wait(1)
		text.Text = "Door will open in 0 seconds"
		wait(1)
		text.Text = "Team, FALL BACK!"
		
--		game.Workspace.TS1.Door1.CanCollide = false
--		game.Workspace.TS1.Door1.BrickColor = BrickColor.new("Sea green")
--		local laser = game.Workspace.TS1.Door1.LaserPlane
--		laser:Destroy()
		text.Door:FireServer()
		wait(5)
		text.Text = ""
		db = true
	end
end

hum.Touched:Connect(OnTouch)

Script (Placed in a folder in ServerScriptService, Human Spawn in Workspace and TextLabel):

game.StarterGui.Timesplitters.TS1Door1.TextLabel.Door.OnServerEvent:Connect(function()
	print("DOOR OPEN DOOR")
	game.Workspace.TS1.Door1.CanCollide = false
	game.Workspace.TS1.Door1.BrickColor = BrickColor.new("Sea green")
	local laser = game.Workspace.TS1.Door1.LaserPlane
	laser:Destroy()
end)

So any ideas to fix this? Thanks in advance!

1 answer

✓ Accepted answer

Hello, I do not have an answer for you, however I have some suspicions. For now, I am simply sending a cleaned-up form of your LocalScript as your’s is very inefficient and messy. This should shorten it and work just the same. Also, a final note, I would suggest placing the RemoteEvent within ReplicatedStorage.

local remoteEvent = game:GetService("ReplicatedStorage")
local humanSpawn = workspace["Human Spawn"]
local textBox = script.Parent
local debounce = false

local function onTouch()
   if (debounce) then return end; debounce = true
   for i = 35,1,-1 do
      if (i==30) then
         textBox.Text = "Door will open in "..i.." seconds"
      elseif (i==10) then
         textBox.Text = "Door will open in "..i.." seconds"
      elseif (i<=5) then
         textBox.Text = "Door will open in "..i.." seconds"
      else
         textBox.Text = tostring(i)
      end
   wait(1) end
   remoteEvent:FireServer()
   wait(5); textBox.Text = ""
end

humanSpawn.Touched:Connect(onTouch)

1 comment

0

Also, my suspicions are that Human Spawn isn’t a BasePart, and is a Model. The Touched event doesn’t invoke on said objects, so you should ensure that it’s a part the player is colliding with. Speaking on the terms of a player colliding with an instance, it should also be clarified that the instance was touched by a player, as it can be fired by other inanimate objects.

This discussion is preserved as it was. New answers, comments, and votes are closed.