I have been working with proximity prompts lately, and in testing today, when a client deleted a proximity prompt, it was also removed for other players.
This is a prompt that was created server side.
So… is there a way to keep the client from deleting server side prompts?
I was in a live game, with FE on, of course
I would think there would be a way to not let this happen as it could be an easy way for a hacked client to really mess up a game.
I tested it and it did not work. Deleting something from the client will not replicate to others, it’s impossible. Exploiters can only delete things inside of their character or parts with ownership set to the exploiter, so, unless you gave ownership of the part containing the ProximityPrompt to the player that destroyed it, there’s no way it replicated to other players.
However, you don’t always have to explicitly give ownership to a player. If the part is unanchored and you don’t explicitly assign the network ownership to nil, Roblox will usually assign it to the closest player’s client.
Roblox has had a weird issue for some time where deletions of instances in a client’s character replicate. You can launch a local server with two players to test this out: delete any limb on one client window, switch to the other client window and look at the other character. This issue is normally why I try, as best as possible, to have each client build their own items onto other characters so that the client-server model can be properly enforced.
Made a solution for this. Instead of putting the proximity prompt in a part in the character, you can put the proximity prompt in a part welded to the player, and as long as the part isn’t a descendant of the player’s character, it’ll work fine to destroy the proximity prompt in a local script without it replicating.
I’m not the most articulate person, so if that didn’t make sense, I wrote out the code for it:
--Script inside of Starter Character Scripts
local Torso = script.Parent:WaitForChild("UpperTorso")
local Humanoid = script.Parent:WaitForChild("Humanoid")
local myPlayer = game:GetService("Players"):GetPlayerFromCharacter(script.Parent)
function CreateProximityPart()
--Creates the part that will be welded to the upper torso--
local PromptPart = Instance.new("Part",workspace.ProximityPartsFolder)
PromptPart.CanCollide = false
PromptPart.Anchored = false
PromptPart.CFrame = Torso.CFrame
PromptPart.Transparency = 1
--Its important to make sure the part is tracable back to the player; this below will work--
PromptPart.Name = myPlayer.Name
--Creates the weld for the part above--
local WeldConstraint = Instance.new("WeldConstraint",PromptPart)
WeldConstraint.Part0 = Torso
WeldConstraint.Part1 = PromptPart
--creates the script that will ensure that after the player has left that the part gets deleted--
local PromptPartScript = script.PromptPartScript:Clone()
PromptPartScript.Parent = PromptPart
PromptPartScript.Disabled = false
--creates the proximity Prompt--
local ProximityPrompt = script.ProximityPrompt
ProximityPrompt.Parent = PromptPart
ProximityPrompt.RevivePromptScript.Disabled = false
ProximityPrompt.Enabled = true
end
--Checks if the part already exists--
if not workspace.ProximityPartsFolder:FindFirstChild(myPlayer.Name) then
CreateProximityPart()
end
Local Script under starter character as well:
--Local Script that will destroy the proximity script on the client only--
local Folder = workspace.RevivePartsFolder
local playerName = script.Parent.Parent.Name
local PlayerFolder = Folder:WaitForChild(playerName,20)
local Prompt = PlayerFolder:WaitForChild("ProximityPartsFolder")
Prompt:Destroy()
And the script that will go under the part:
--The script that will ensure that after the player has left that the part gets deleted--
local name = script.Parent.Name
while wait(3) do
local ifPlayer = game:GetService("Players"):FindFirstChild(name)
if not name then
script.Parent:Destroy()
end
end
If anything is above is wrong, please correct me, otherwise I hope this helps a little!