In order to try and prevent item duplication when picking up items using the proximity prompt, I had thought up a method where only one person can pick up an item at a time.
However, how would I check to see if a prompt is already being used by another player? Or
How would I hide the prompt to all other players except for the player triggering the prompt?
I want to see if there’s any solutions apart from using remote events of course.
No, I mean you could check whether Used is true or false to know if another player is holding it and also:
local user
button.PromptButtonHoldBegan:Connect(function(player)
if user == nil then
user = player
else
print("another player attempted to hold")
end
end)
button.PromptButtonHoldEnded:Connect(function(0layer)
if player == user then
user = nil
end
end)
button.Triggered:Connect(function(player)
if player == user then
print("a")
--do stuff
end
end)
The logic here is as the first person touches the button, they are set as the user variable, and they would be the only one that can trigger it because the triggered event has an if player == user, also they are the only one that can set the variable to nil so that if someone else holds it then unhold, it won’t reset the variable.
Except, since this is being done on the client-side, the user variable wouldn’t be affected by other clients when they hold the prompt. Hence it won’t work.
I’ll keep the thread open but I’m just going to use remote events for now.