Identify if the user no longer touches a part

I’m attempting to create a board in which changes the textlabel’s text to the user’s sent message, but I’m struggling on when the user leaves the platform - it doesn’t change the text when TouchEnded event was activated - however, it ignores it for some reason and I can’t identify the issue. What’s the concurrent issue here? The code’s:

local model = game.Workspace.Speaker
local board = model.Board
local speakerTouched = model.SpeakerTouch
local text = board.SurfaceGui.Frame.TextLabel
local changeText = false

game.Players.PlayerAdded:Connect(function(plr)
	speakerTouched.Touched:Connect(function()
	  if plr:GetRankInGroup(3788654) == 255 then
	  if not changeText then
		print(plr.Name.." is rank 255!")
		plr.Chatted:Connect(function(message)
			text.Text = message
		end) end
	else
        print(plr.Name.." isn't rank 255!")
	end end) 
		speakerTouched.TouchEnded:Connect(function()
		changeText = true
		return
		end)
end)
-- this is in ServerScriptService

Example: https://gyazo.com/db0d72c54cc085182ecab9bb5a49b57a

1 Like

Why did you put a TouchEnded inside Touched? Also, you only need to do Touched and not PlayerAdded

part.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)

You may want to make a while loop where you use

thing:GetTouchingParts()

which returns an array of parts that collide

The entire script is perfectly fine, however, regardless of the response - I’m having issue with TouchEnded event, as I’m attempting to correspond when the player leaves, it doesn’t fire a signal to change the board’s text to their message when away.

You are attempting to make a TouchedEnded event while inside the Touched event. Both should be separated…

script.Parent.Touched:Connect(function()
end)
script.Parent.TouchedEnded:Connect(function()
end)

For your case:

game.Players.PlayerAdded:Connect(function(plr)
	speakerTouched.Touched:Connect(function()
	  if plr:GetRankInGroup(3788654) == 255 then
	  if not changeText then
		print(plr.Name.." is rank 255!")
		plr.Chatted:Connect(function(message)
			text.Text = message
		end) end
	else
        print(plr.Name.." isn't rank 255!")
	end end) 
speakerTouched.TouchEnded:Connect(function()
		changeText = true
		return
end)
end)

I have already separated both functions, and yet it still fires a signal when a user talks AWAY from the platform that distributes the signal. I updated the code for concerns.

Hardly can find anything that works:

Alternatively, you could use Region3 to substitute the functionality instead. Sometimes the TouchEnded is not completely reliable at all times.