How do I make an object disappear locally once a proximity prompt is pressed?

So basically, I’m trying to make an item on the floor disappear locally once a prompt is activated.

The problem is, I do not know how to do this AT ALL. (that’s why I’m positing this lol)

I’ve tried to search all over DevForum, but found nothing. Any help?

1 Like

Use local script, when proximity prompt is triggered, just destroy the object.
Once the object is destroyed in local script on client side, it’ll not be propagated and so nothing will happen to such object on server or other clients.

myProximityPrompt.Trigger:Connect(function()
    myPart:Destroy()
end)

If a listener to proximity prompt is created in a local script on client side, it’ll also not be propagated, and so will be created only for client who have this script.

3 Likes

where would I put the local script exactly? tried putting it in the proximity prompt and it didn’t work.

1 Like

You can try putting it into parent object of proximity prompt, for example a part.
Send a console log if it won’t work, so I can see what errors have appeared.
Try to debug your code using breakpoints or print statements.

print("Local script start")
...
print("Local script end")
1 Like

you would put it in StarterPlayerScripts
you could also check if You are the one triggering the prompt

myProximityPrompt.Trigger:Connect(function(player)
  if player == game.Players.LocalPlayer then
    myPart:Destroy()
  end
end)
1 Like

If it is in local script, the event is not propagated to other player, and so the check is not needed. It would be important only in case it is in server script.

1 Like

No?

The Event will still Fire everytime the ProximityPrompt is Triggered, and will still return the Person who Triggered it, only Difference is that the event is occuring only on the Client.

I’m not sure where you got this Information from.

2 Likes

First, LocalScripts don’t work in Workspace, that’s why your script didn’t work when you put it inside the ProximityPromt.

You should instead use ProximityPromtService inside of the script and put the LocalScript in either StarterGui, StarterPack or StarterPlayerScripts.

4 Likes

That would make no sense if a listener created entirely on client would trigger someone’s else trigger event. I’m using it myself, and I’m pretty sure a local script won’t trigger someone’s else interaction, only local player’s.
Ultimately there’s no need to check for the player if it’ll always be a local player.

Nobody is saying that, When you Connect an Event and it Fires (Probably with the Exception from Client to Server), It will Fire no Matter the Environment its in, Thats how Events work, and Always have.

Again, This is an incorrect statement.

For Example, If you connect a PlayerAdded event on the Client, It will function how it normally would, It will give you the Player that joined.

This is literally how it works. Only exception where you use a Player provided parameter is on server-side.

PlayerAdded will be trigger for every player since Player object is also spawned on every other client.
You cannot listen to events trigger by other players of keyboard clicks.

Where are you getting this Information from? Thats the real Question.

PlayerAdded is done on the Server, otherwise it would be crazy insecure, And All Server Changes Replicate to the Client.

In what universe this would be an insecurity? Obviously server will invoke, that player has joined since server is the socket handler. However server doesn’t know about player clicking a proximity prompt if the prompt is defined in a local script. Server doesn’t know about any client script, this implies that other players cannot know about someone elses proximity prompt usage.

You still have the option to try it in Studio. I have it all tested and checked.

@Cloudy71 should be correct

how would 1 player’s prompt trigger another player’s prompt
that’s like 1 textbutton being pressed for every player
it wouldn’t work so the check is just useless

i simply didn’t think about it before i posted my example

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.