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.
When the server shows the frame to a player, both will see that the frame is Visible. However, if you decide to close it on the client, the server will still see that the frame is Visible, because client actions won’t be replicated to the server.
You may want to use a RemoteEvent instead, and tell the server to close the dialogue there as well.
Either do both of them locally, or both of them on the server.
Doing both of them locally seems like the better thing to do since the first script will already work on a local script and there’s no need to tweak it. Also, its GUI.
Let’s go over this again. Your issue here is that:
From the server, you show a player’s GUI by setting Visible to true.
From the client, you hide it by setting it to false.
If you think that’s how it works, have fun figuring out the issue.
Because what you’re doing is exactly the issue.
Remember how server and client works?
Server changes are visible to the server and ALL the clients.
Except animations, client changes are ONLY visible to the own client.
Say with an example:
If you create a part using a Server script, everyone can see it.
If you create a part using a LocalScript, only the client can see it, but still be able to use it. With this example in place, everyone else will see you flying because they don’t see a part, since only you have it.
Get it now? What do you think your issue is?
When you set the Frame to Visible from a Server script, changes are visible to both the server and that client.
Now I want you to listen to this very carefully: If you close the frame on the client, only the client will see that it’s closed. This means that the server still thinks that Frame.Visible = true, so
script.Parent.Triggered:Connect(function(player)
local npcDialogueFrame = player.PlayerGui.MainGui.NpcDialogueFrame
npcDialogueFrame.Visible = true
-- it's already true so it does nothing.
end)
no longer works because it’s already true.
Your issue has two fixes: Either place the Prompt script in a LocalScript, or use a RemoteEvent. It’s as simple as this.
No I only make it visible for the client and inviseble for the client to thats why its
player.PLayerGui
And the player = the player who triggerd the proximity promt and in the other script it just closes the gui also for that player because theres a buttin that frame that closes what ever frame the button was inside of so it does the client both true and false, I fixed it btw by making them both in starterGui and local scripts.
OK, let’s use the commander analogy.
Pretend you are the commander (the server) of a giant army. The army is split into divisions (clients). The divisions know what the instructions from the commander are, but, the problem is, the commander doesn’t know what is going on at the battlefield with the divisions. The commander needs messengers (remote events).
These messengers will tell the commander what is going on, and the commander can send a reply to singular divisions with instructions.
Remote events work the same way - the server wants to know what’s going on, so a client can send that info.
Create a remote event in ReplicatedStorage. Let’s call it VisibleRemote.
To let the server know if it’s visible, we can use :FireServer on a local script