You have quite a few issues here that need fixing before your visibility script will work.
1.) For making User Interface objects visible when a part is touched, you have to send a signal through a RemoteEvent that tells a local script to call a function. That function would then make the text labels invisible or visible based on a parameter you might give it.
For the following code block to work, you need to follow these steps.
1 - Put a RemoteEvent in ReplicatedStorage named 'SetVisible'
2 - Make a local script inside the ScreenGui that is inside the StarterGui
3 - Put the following inside the local script.
local TextLabel1 = script.Parent.TextLabel1
local TextLabel2 = script.Parent.TextLabel2
local RemoteEvent = game.ReplicatedStorage.
local function SetVisiblity(val)
if val == true then
TextLabel1.Visible = true
TextLabel2.Visible = true
else
TextLabel1.Visible = false
TextLabel2.Visible = false
end
end
RemoteEvent.OnClientEvent:Connect(function(val)
SetVisibility(val)
end)
This will make it so that when you call the RemoteEvent (aka RemoteEvent:FireClient(Player, true)) it will set the text label to the bool value you give it.
2.) You are trying to make the objects inside StarterGui visible, which isn't the player's actual menu. The player's actual menu is within the player itself. It's name is PlayerGui. However you can't access anything inside of the player's GUI from the server side, so you need to have a local script inside the StarterGui or ScreenGui to control everything.
1 comment
in line 9 i get the error saying "Error: (9,1) Expected identifier, got 'local'", and when i delete local it says the same thing but instead of local its "function"