Why is my onTouch script not working?

Hello forum, I was making a system where when the player walks into a part a script activates and a BillboardGUI frame tweens down, (This is a regular script because apparently, Roblox doesn’t allow LocalScripts in BillboardGUI), it hasn’t worked once to tween the UI down when a player goes into the part and I am very stressed, I’ve tried posting about it, I’ve tried doing it myself, nothing has worked.

local chat = script.Parent
local child = script.Parent.Text

local touching = false

chat.Visible = false
child.Visible = false

local function onTouch(hit)
	print("Touched")
	local player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
	if player and not touching then
		print("Found Player")
		chat.Visible = true
		chat:TweenSize(

			UDim2.new(0, 252,0, 50), --End size
			Enum.EasingDirection.Out,
			Enum.EasingStyle.Elastic,
			2

		)
		print("Tweened")

		child.Visible = true
		touching = true
	end
end

local function onTouchEnded()
	if touching then
		print("Touch has ended")
		chat.Visible = false
		child.Visible = false
		touching = false
	end
end

game.Workspace.Characters.Cardinal.Activator.Touched:Connect(onTouch)
game.Workspace.Characters.Cardinal.Activator.TouchEnded:Connect(onTouchEnded)

print("Done")

try this and let me know if there’s anything wrong with it:
(also if you want this client sided and not server sided i can try doing that)

game.Workspace.Characters.Cardinal.Activator.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
	
		chat.Visible = true
		chat:TweenSize(

			UDim2.new(0, 252,0, 50), --End size
			Enum.EasingDirection.Out,
			Enum.EasingStyle.Elastic,
			2

		)
		print("Tweened")

		child.Visible = true
		
	end
end)


game.Workspace.Characters.Cardinal.Activator.TouchEnded:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		
		print("Touch has ended")
		chat.Visible = false
		child.Visible = false
		
	end
end)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.