Basically, I am trying to make it so if a player touches a brick that is X:10 Y:0.2 Z:10, then a the text in a text label from a Surface GUI changes. This part I managed (was meant for explanation)
However, I cannot make the text from the text label that is inside the Surface GUI change back to what it previously was. I tried using the below script, but the issues is if the player moves on the brick (as it is big enough for a player to move around on it without stepping down from it), it changes text back and forth instead of remaining the same.
Here is the script. I would gladly appreciate the help and an explanation.
local Text = script.Parent.Parent.SGPanel2.SurfaceGui.MainFrame.PlayerID
script.Parent.Touched:connect(function(hit)
if (hit ~= nil) then
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
if (plr ~= nil) then
Text = "Your Id is:" .. plr.UserId
end
end
end)
script.Parent.TouchEnded:connect(function(hit)
if hit.Parent and game.Players:GetPlayerFromCharacter(hit.Parent) then
Text = "Step on the pad to find out your ID"
end
end)

4 comments
On line 12, when the touch ends I don't think it gives the part that stopped touching it. I could be wrong. There is a problem with this if there are multiple people touching this. So you could use the touched function and stuff in a local script in the player's StarterPack or something.
But in your situation, try getting rid of line 13 and 15 completely. There is no point of it being there, and I'm quite certain that's what's causing the problem.
So, I got rid of lines 13 and 15 and nothing changed. Basically, the script works just like before, but if I walk around on the 10x0.2x10 brick, the text keeps flickering, either showing the ID or showing the "Step on the pad..." every time I move on the brick (to be clear, I am not getting on and off the brick, I am on it, moving).
Ah, try asking a professional. And drink some milk. I would also suggest wearing your lucky socks and eating a four leaf clover. You have to eat it, contrary to popular belief.