✓ Accepted answer
First of all. USE CODE BLOCK. Press that lua button on top of this textbox thing, and it'll come up with these ~~~.
Secondly, check if it's a local script, and make sure it's parented either under StarterPlayerScripts or StarterGui. Your TextLabel is parented under Part, which is not necessary at all. Instead, parent it to the ScreenGui, and set the Visible property to false so that the player doesn't see the TextLabel.
Thirdly, if you wanna do Open GUI when someone touches part, you will need to use a Remote Event.
Server Script (The parent is your specific part)
local remote = game.ReplicatedStorage.RemoteEvent
script.Parent.Touched:Connect(function(hit)
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
remote:FireClient(plr)
end)
(Note: I haven't added a debounce, so it's highly recommended that you add one.)
Local Script (The parent is your ScreenGui)
local remote = game.ReplicatedStorage.RemoteEvent
local textLabel = script.Parent.TextLabel
remote.OnClientEvent:Connect(function()
textLabel.Visible = not textLabel.Visible
end)
I recommend you use what I said above, just set the Visible property, you don't need to set the parent.
(Note: I noticed you have a dialogue thing, just use TextLabel.Text to change the dialogue.)
4 comments
why would u wanne change the parent?
is it to make a gui visible?
I want to change the parent so I can add some dialouge to the game
if anyone would like to see the full script, i'll gladly show it