UI script problem!

Hello there,
I am working on a horror game,
I have a meshpart called “Walkie Talkie” and I am trying to use a proximity prompt to make a an image frame visible the after five seconds, invisible.

local WalkieTalkie = script.Parent

local screenGuiPath = game.StarterGui:WaitForChild("ScreenGui")
local imageLabel = screenGuiPath:WaitForChild("ImageLabel")

game.Workspace.WalkieTalkie.ProximityPrompt.Triggered:Connect(function(playerWhoTriggered)
	if playerWhoTriggered:IsA("Player") then
		imageLabel.Visible = true

		wait(5)

		imageLabel.Visible = false
	end
end)

If anyone could help me, I would extremely grateful.

3 Likes

Changing things on StarterGui will not be replicated to the client ingame

local WalkieTalkie = script.Parent


game.Workspace.WalkieTalkie.ProximityPrompt.Triggered:Connect(function(player)
	local screenGuiPath = player.PlayerGui:WaitForChild("ScreenGui")
	local imageLabel = screenGuiPath:WaitForChild("ImageLabel")
	imageLabel.Visible = true

	wait(5)

	imageLabel.Visible = false
end)
3 Likes

Thank you so much! I will try this now.

1 Like

I would use this as a local script inside the gui itself as it is for the client.

local WalkieTalkie = workspace:WaitForChild("WalkieTalkie", 1)
local Prompt = WalkieTalkie:WaitForChild("ProximityPrompt", 1)

local Gui = script.Parent
local ImageLabel = Gui:WaitForChild("ImageLabel", 1)

Prompt.Triggered:Connect(function(player: Player)
    if player ~= game:GetService("Players").LocalPlayer then return end

   ImageLabel.Visible = true

    task.wait(5)

    ImageLabel.Visible = false
end)
3 Likes

Is this so that only the player who triggered the prompt will see the gui?
Anyway, let me test it.

1 Like

Is this so that only the player who triggered the prompt will see the gui?
Anyway, let me test it.

1 Like

Is this so that only the player who triggered the prompt will see the gui?
Anyway, let me test it.

1 Like

It’s a server script not a local script (and maybe who knows if the op wants it to be server sided?)

2 Likes

I’m saying as it is easier and better practice to do all UI related stuff on the client

2 Likes

I tried putting Sinsbygod’s script in the serverscript service, it still does not work.

1 Like

You would put it in the ScreenGui that has the imagelabel and it’d be a LocalScript.

1 Like

I have tried that, but I will do it again, I might have done it wrong.

1 Like

Thanks! both of these scripts work.

1 Like

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