Get parts name and display it on ui

Hello, so i was wondering how i would be able to, when a part is touched a UI appears saying ‘NOW ENTERING’ then under i want it to display the parts name in a label.

Something to replace the ‘TextTemplate’
image

1 Like
zone.Touched:Connect(function(hit)
    if hit:IsDescendantOf(game.Players.LocalPlayer.Character) then
        UI.Title.Text = zone.Name
        -- other animation code here
    end
end)
1 Like

Hey thanks for the swift response.

What would zone =
As right now if i used that code it will display red under it.

It’s the part that you are detecting touchs for, I’m assuming it’s a zone that is uncollidable and invisible?

Thanks, so much. Yeah just managed to manipulate it to fit into my scene. Just a bit sleepy lol so not thinking correctly. And once again thanks for the swift response

Hey i appear to be getting this issue. I did slightly alter the code to fit with my game.

local players = game:GetService("Players")
local Part = script.Parent
local StarterGui = game.StarterGui

Part.Touched:Connect(function(hit)
	if hit:IsDescendantOf(game.Players.LocalPlayer.Character) then
		StarterGui.Region.Frame.Change = Part.Name
		game.StarterGui.Region.Frame.TextLabel.Visible = true 
		game.StarterGui.Region.Frame.Change.Visible = true

		wait(2)

		game.StarterGui.Region.Frame.TextLabel.Visible = false 
		game.StarterGui.Region.Frame.Change.Visible = false


	end
end)

Four things:

  • You shouldn’t be modifying StarterGui
  • This script is server sided
  • Frame.Change is not a valid member of ‘Frame’
  • Use task.wait() instead of wait().

You’d need this script to run locally for this to work correctly. And, modify game.Players.LocalPlayer.PlayerGui instead of game.StarterGui.

Sorry for late response, I went to work on something else!

Hello, i’m really confused. So what should it look like. Btw ‘Change’ is the name of my text label i want to change.

Here is what my studio looks like now.

Use Frame.Change.Text = instead!

Still doesn’t show when touched.

I see in the image that the script is in the workspace. LocalScripts will not run in this location, consider making this work when placed in the player’s gui.

Also like I said before, modifying StarterGui is not a good idea, since it’s not the player’s UI.

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