How would I make this show up only if your in a zone?

Hello! I have a glitch effect and I want it to show to the player who is touching it and only show when your in the part. How would I make this work?

LocalScript 1

script.Parent.Touched:Connect(function()
	local Glitch = script.Parent.GlitchEffect:Clone()
	Glitch.Parent = game.Players.LocalPlayer
	Glitch.Enabled = true
end)

LocalScript 2

while wait(0.1) do
	if script.Parent.Enabled == true then
		script.Parent.Glitch:Play()
		script.Parent.ImageLabel.Visible = true
		wait(5)
		script.Parent.Enabled = false
	elseif script.Parent.Enabled == false then
		script.Parent.Glitch:Stop()
		script.Parent.ImageLabel.Visible = false
	end	
end

You can use Touched and TouchEnded events.

For example:

script.Parent.TouchEnded:Connect(function()
     Glitch.Enabled = false
end)

Forgot it existed since I havent used touched in a while. Thank You!

1 Like

No worries, glad I could help!