Proximity Promt Doesnt Work Twice Problem!

For some reason this prximity promt wont work the second time this is normal script.

script.Parent.Triggered:Connect(function(player)
	local npcDialogueFrame = player.PlayerGui.MainGui.NpcDialogueFrame -- this is where it stops the second time
	
	npcDialogueFrame.Visible = true
	
end)

And this is a local script wich closes teh gui I opend in script 1.

script.Parent.MouseButton1Up:Connect(function()

script.Parent.Parent.Visible = false

end)

Its because client is controlling its own gui, turning it not visible, and you are asking the server to handle that too.

You could use remotes from server to client when the prompt is triggered to hide/unhide the gui. Or handle the visibility of the gui from client side using the prompt triggered event in the local script too, so client controls its own gui visibility instead of server.

Can you please show me how to do that

Yup, but, which approach?
Here is an example of client sided.

Your local script should have something like this, just reference your prompt in the script:

-- your prompt path
local Prompt = game.Workspace:WaitForChild("PromptModel"):WaitForChild("ProximityPrompt") 

Prompt.Triggered:Connect(function() -- the trigger
	script.Parent.Parent.Visible = true -- turn visible
end)

script.Parent.MouseButton1Up:Connect(function()
	script.Parent.Parent.Visible = false
end)

The server script that should handle the server functions:

script.Parent.Triggered:Connect(function(player)
-- Server Functions not related with client guis
end)

The other approach, If you want to use the server to tell the client to show the gui you will need remotes