Local script not working

Hi all
i am making a horror game and i was working on the player dialogue but for some reason the script wouldn’t work!

Here’s the script

local Trigger = game.Workspace.HallTrigger
local textlable = script.Parent.TextLabel

local function typewrite(object,text)
	for	i = 1,#text,1 do
		object.Text = string.sub(text,1,i)
		wait(0.05)
	end
end




Trigger.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		Trigger:Destroy()
		typewrite(textlable,"what?")
		wait(2)
		typewrite(textlable,"They din't even unpack...")
		wait(3)
		typewrite(textlable,"must have left in a hurry")
		wait(4)
		textlable.Visible = false
	end	
end)

btw there is another local script in the same screen gui
image

This is the other script and also the one that works

local Trigger = game.Workspace.Entry
local textlable = script.Parent.TextLabel

local function typewrite(object,text)
	for	i = 1,#text,1 do
		object.Text = string.sub(text,1,i)
		wait(0.05)
	end
end




Trigger.Touched:Connect(function()
	Trigger:Destroy()
	typewrite(textlable,"Hey everybody i am home!")
	wait(3)
	typewrite(textlable,"Huh?")
	wait(1)
	typewrite(textlable,"Any one home?")
	wait(4)
	typewrite(textlable,"I guess they must have gone out")
	wait(4)
	textlable.Visible = false
end)

I might be wrong but try doing a denounce on both of the touch event functions and then move the destroy line to after you set the textlabel to invisible.

Your destroying the part therefore the part won’t be detecting touched events anymore so just make its Transparency 1 instead and Can-Collide off.

same as sam (@wesam1992), you are destroying the part.

Or you can try and destroy it after you’ve done everything (If the part is a one-time use), but I suggest just putting its Transparency + Its Can-Collide on

It’s meant to be destroyed, when the touched event fires, that’s all it needs to continue the given code. It shouldn’t be a problem.

The only thing I could think of is the object doesn’t actually exist upon getting touched. The codes are virtually the same, I don’t see any typos or anything.

Check all other scripts for signs of possible removal of the part, otherwise there’s nothing wrong.

You are not setting textlable.Visible = true before showing the text, the rest of the code should work.