I made an object carrying script using prompt’s, all of it handled by 1 server script, with the objects and player having BoolValue attributes of being carried.
What is the issue? The issue is I am trying to make it where the prompt is disabled on client side if the object is being carried by a different player, I wrote it in many different ways in the local script, even tried bindable events but couldn’t figure it out
What solutions have you tried so far? I looked at past posts, tried to apply the same logic from the API. no luck. Can’t figure out where the issue is, in most cases it doesn’t print out any errors
The prompt should only be visible for the carrier
This is the local script code. If you would like to see pervious code attempts or the main handler please ask.
local PPS = game:GetService("ProximityPromptService")
local Player = game.Players.LocalPlayer
PPS.PromptTriggered:Connect(function(prompt, playerToDisableFromt)
print(prompt)
local crate = prompt.Parent
print(crate)
if crate:GetAttribute("isCarried") == true and crate:GetAttribute("Carrier") ~= Player.Name then
prompt.Enabled = false
elseif prompt.Parent:GetAttribute("isCarried") == false then
prompt.Enabled = true
end
end)
A player grabs a crate, then the prompt from that crate should be hided in All Clients, except the one who activated it
The prompt changes text to Drop instead of Grab for the player who is holding it
Once player activates Drop prompt again, drops the box, change text back to Grab, and enable that prompt to All Clients again ?
Thats the goal?
You tried using a remote:FireAllClients(crate) so each client is asked to hide the prompt which is inside that crate when any player triggered the function connected to the Prompt?
(should be done in server side, which would hide the prompt for all players)
Or instead of FireAllClients(), iterate all players in game, FireClient(player, crate) for all except the player that Fired the event of grabbing a crate
I think the issue could be in how you are handling the prompt triggered.
There is a special reason why everything is client sided?
I would try this.
A ServerScript using the PPS, listening all prompts fired. When a signal is received and prompt being check, perform a loop with game.Players:GetPlayers(), and remote:FireClient(player, prompt) to all players except the main player who activated the prompt.
In a Local Script, you listen the remote signal, and hide the prompt received by the client.
In that way, nobody can see the prompt except the player who activated it
The server script listening the prompts, and asking all clients except the owner of the crate to hide that prompt:
(there is a RemoteEvent in replicated storage to handle the client side)
local PPS = game:GetService("ProximityPromptService")
local RemoteEvent = game.ReplicatedStorage:WaitForChild("RemoteEvent")
PPS.PromptTriggered:Connect(function(prompt, plrFired)
warn(prompt, "fired by:", plrFired) -- a prompt fired by a player print
if prompt.Name == "CratePrompt" then -- a check of the prompt
for _, plr in pairs(game.Players:GetPlayers()) do -- Firing all clients in a loop
if plr ~= plrFired then -- fire all clients except the one that fired the prompt
RemoteEvent:FireClient(plr, prompt)
else
-- Change text on prompt for the player holding the crate
-- functions etc
end
end
end
end)
And a Local Script all clients should have, that will listen the call from server to hide an specific prompt:
local RemoteEvent = game.ReplicatedStorage:WaitForChild("RemoteEvent")
RemoteEvent.OnClientEvent:Connect(function(prompt)
warn("prompt to hide on this client", prompt)
prompt.Enabled = false
end)
I meant this script is client sided (the issue in question):
If you handle the Enabled property in that client side script, the only player that will perceive the changes of those prompts would be the client itself, and no way to tell other clients to hide or unhide the prompt, only server can do that, thats why I suggested, handle the PromptTriggered event on ServerSide by using something like the first script I sent in this message.
(or let the client Fire a remote to server, then server fire a remote to all other clients… but if ProximityPrompt already does that, no need for extra remote calls)
Everytime that a player activates a prompt, is asking server to perform a little loop to fire a remote to “all clients”. Logical the more crates and the more players the more calls to server to perform that loop and fire remotes. Woulf be about testing it.
And improve the approach, maybe trying to hide the prompts server side, it will reflect the same way as using the remote. Once you get the call on the ServerScript, hide that prompt in server side, and use a remote to ask the owner of the crate to be one that has the prompt enabled.
In that way you skip the remote call on a loop to all other clients, and would be hiding that prompt on serverSide.
The amount of crates, remotes calls, etc, I think will depend on the security you want for your system, cause, if you dont want exploiters doing everything they want, you need to rely on server, but, at some point you could reach a limit of what server can handle. So, I think everything depends on all the systems that server should handle at the same time, taking in count the best possible security/sanity check, so, at some point, theres a limit of how many checks the server can handle, and that will tell you the max amount of checks/systems/crates etc that should be secured or needed the server to handle it.