Script doesn't make TextLabel visible

Here is my code :

local ProximityPrompt = script.Parent
local Rat = game.StarterGui.ScreenRat

ProximityPrompt.Triggered:Connect(function()
	script.StarterGui.ScreenRat.TextLabel.Visible = true
	
	wait(5)
	script.StarterGui.ScreenRat.TextLabel.Visible = false
	
	
end)
	

It’s supposed to make the TextLabel visible when press E. It has a proximity prompt on the part.
However , The script isn’t working and it has no errors.
Does anyone know how to fix?

1 Like

Local scripts cannot run inside of Workspace, you’ll need to use remote events for that.

try this

local ProximityPrompt = script.Parent

ProximityPrompt.Triggered:Connect(function(player)
	player:WaitForChild("PlayerGui"):WaitForChild("ScreenRat").TextLabel.Visible = true
	
	wait(5)
	player:WaitForChild("PlayerGui"):WaitForChild("ScreenRat").TextLabel.Visible = false
	
	
end)
1 Like

Try putting a RemoteEvent in ReplicatedStorage, insert a script in the ProximityPrompt and write this in it.

local replicatedStorage = game.ReplicatedStorage
local remoteEvent = replicatedStorage.RemoteEvent

script.Parent.Triggered:Connect(function(playerWhoTriggered)
   remoteEvent:FireClient(playerWhoTriggered)
end)

Now, we need it to actually make the label visible. Insert a local script in the label and write this in it.

local replicatedStorage = game.ReplicatedStorage
local remoteEvent = game.RemoteEvent

remoteEvent.OnClientEvent:Connect(function()
   script.Parent.Visible = true
   wait(5)
   script.Parent.Visible = false
end)

Hope this helped.