How to make UI.Enabled with proximity promot server sided

I’m right now trying to achieve results when UI.Enabled will work server sided with use of proximity prompt.

I’ve tried a few ways with remote events but actually back upped script, since I didn’t had lot of experience with the remote events.

Currently code looking like that:


ProximityPrompt.Triggered:connect(function(Player)

    Player.PlayerGui:FindFirstChild("AJ").Enabled = true
     Player.PlayerGui:WaitForChild("AJ").Frame.TextLabel.ScrollScript.Disabled = false
end)```
1 Like

Hello, while this script should work and you should be able to set the properties of GUIs on the server, it also depends on where your script is located. Could you let me know where the script is parented to?

It is a group, in workspace. Parent for script is ProximityPromot.

Also could you show the part where you index the proximity prompt, I was testing this code in a studio with the same scenario and it was working fine for me.

Current problem is that it works, but only for client. So, everyone in server didn’t had any changes, UI didn’t pop up for them
great_png

If you are saying you want the GUI changes to replicate to other clients, ROBLOX only has it show changes in properties of the GUI to the GUI owners client, and the server. Your GUI will not replicate to other clients not owned by you.

Exactly, that’s what I need. It have to replicate on other player, however all my previous attempts to do so failed, therefore I came up on devforum.

Sorry for the misunderstanding earlier then, but here is another question. How do you show one players gui to the other clients and why?

It is supposed to be some kind of socio status display, basically everyone would know that City Lockdown or something like that is going on. I tried to replicate UI with use of Remote Events, so when proximity prompt was triggered, it did FireServer. Before there was another script in the ServerStorageService, which was waiting for event afterwards it had to enable gui. However, it didn’t work.

So basically, are you saying you want all the other guis to change dependant to one clients gui? And my other question is that when you are saying you used FireServer, were you using it on the server or client?

Actually, some kind of so. I need it to turn on (enabled = true) for everyone who is on server at that moment. Basically when Prompt getting triggered it should be supposed make AJ.Enabled = true. FireServer was on the server, however, it didn’t work.

I see, so instead of setting only the players gui who activated the prompt, you should loop through every player and set their gui instead. Also you can’t use FireServer on the server, you have to use FireClient (Or in this case FireAllClients) in order to send a message to the client.

How it would look then, do you have any examples through? Because I don’t have a lot of experience with the replicates.

If you wanna loop through players you can do this:

for i,Player in ipairs(game.Players:GetPlayers()) do
       -- You can do stuff with the Player variable here, Player is the player
end
1 Like

Helped a lot. However is there anyway that also people who will join will get this UI too if it is enabled true?

Yes, you can have the script listen to a .PlayerAdded connection (Connection from Players service) and have it wait for their gui to load and then do what you need to do.

1 Like

I’m not fully sure, but how would it look then?

You could do this:

game.Players.PlayerAdded:Connect(function(Player)
       local PlayerGui = Player:WaitForChild("PlayerGui")
       local AJ = PlayerGui:WaitForChild("AJ")
end)
    for i,Player in ipairs(game.Players:GetPlayers()) do
    Player.PlayerGui:FindFirstChild("AJ").Enabled = true
     Player.PlayerGui:WaitForChild("AJ").Frame.TextLabel.ScrollScript.Disabled = false

game.Players.PlayerAdded:Connect(function(Player)
       local PlayerGui = Player:WaitForChild("PlayerGui")
       local AJ = PlayerGui:WaitForChild("AJ")
             end)
       end
end)```

You will have to put the connection outside the loop and decide what you want to do with “AJ” like in the loop