In short, to prevent exploiters taking advantage of certain things such as deleting scripts inside of their character, how could the server-end take notice and action against things like this?
put this in StarterCharacterScripts
local Character = script.Parent
Character.DescendantRemoving:Connect(function(Descendant)
--YourCode
end)
or if you want to check if the player deleted a specific Instance you can do
local Character = script.Parent
Character.DescendantRemoving:Connect(function(Descendant)
if Descendant:IsA("BasePart") then --/Tool/Script/LocalScript..etc
end
end)
Well, if an exploiter is to delete a ServerScript that is placed inside of their character, this would replicate to the server
the server cannot see client changes.
You can use .ChildRemoved event if something is removed?
ChildRemoved will ONLY
check if a children from the character is removed.
however DescendantRemoving
will check for every Descendant that is being removed inside the Character.
Objects that are deleted from inside of the character will replicate if done on the client. You can test this yourself by deleting something on your character in studio while on client, then swap to the server.
even if the exploiter deletes the ServerScript it will only replicate to the client and the ServerScript will still be there.
Just tested this, it will be gone on the server too.
yes ik the server is able to detect if something from the player character is removed but it won’t work 100% right, for example if you try to delete a sound from the character the serverscript won’t detect that, anyways isn’t this post solved yet?
Just listen for Character.ChildRemoved
or Character.DescendantRemoving
on the server (via a script inside the ‘ServerScriptService’ container).
If a client destroys instances inside its characters those destructions will replicate to the server.
Try to destroy a sound instance inside the player character using a script it won’t replicate to the server.
I did and its deletion replicated to the server.
i tried it myself and it doesn’t get replicated to the server.
--SERVER
local Game = game
local Players = Game:GetService("Players")
local function OnPlayerAdded(Player)
local function OnCharacterAdded(Character)
local Sound = Instance.new("Sound")
Sound.Parent = Character
print(Sound.Parent) --Character's name.
task.wait(1)
print(Sound.Parent) --nil
end
Player.CharacterAdded:Connect(OnCharacterAdded)
end
Players.PlayerAdded:Connect(OnPlayerAdded)
--CLIENT
local Game = game
local Players = Game:GetService("Players")
local Player = Players.LocalPlayer
local function OnCharacterAdded(Character)
local Sound = Character:WaitForChild("Sound")
Sound:Destroy()
end
Player.CharacterAdded:Connect(OnCharacterAdded)
try to delete any sound instance in the Character’s HRP
this will not replicate to the server
a script in StarterCharacterScripts :
local char = script.Parent
char.DescendantRemoving:Connect(function(Descendant)
print(Descendant)
end)
however doing this locally will work just fine.
--SERVER
local Game = game
local Players = Game:GetService("Players")
local function OnPlayerAdded(Player)
local function OnCharacterAdded(Character)
local Root = Character:WaitForChild("HumanoidRootPart")
local Sound = Instance.new("Sound")
Sound.Parent = Root
print(Sound.Parent) --HumanoidRootPart
task.wait(1)
print(Sound.Parent) --nil
end
Player.CharacterAdded:Connect(OnCharacterAdded)
end
Players.PlayerAdded:Connect(OnPlayerAdded)
local Game = game
local Players = Game:GetService("Players")
local Player = Players.LocalPlayer
local function OnCharacterAdded(Character)
local Root = Character:WaitForChild("HumanoidRootPart")
local Sound = Root:WaitForChild("Sound")
Sound:Destroy()
end
Player.CharacterAdded:Connect(OnCharacterAdded)
yes i know this will destroy the part on the client and it will replicate to the server,
try the script above that i sent in a localscript/serverscript.
--SERVER
local Game = game
local Players = Game:GetService("Players")
local function OnChildRemoved(Child)
print(Child.Name) --Sound
end
local function OnPlayerAdded(Player)
local function OnCharacterAdded(Character)
local Root = Character:WaitForChild("HumanoidRootPart")
Root.ChildRemoved:Connect(OnChildRemoved)
local Sound = Instance.new("Sound")
Sound.Parent = Root
end
Player.CharacterAdded:Connect(OnCharacterAdded)
end
Players.PlayerAdded:Connect(OnPlayerAdded)
--CLIENT
local Game = game
local Players = Game:GetService("Players")
local Player = Players.LocalPlayer
local function OnCharacterAdded(Character)
local Root = Character:WaitForChild("HumanoidRootPart")
local Sound = Root:WaitForChild("Sound")
Sound:Destroy()
end
Player.CharacterAdded:Connect(OnCharacterAdded)
We’re polluting this thread with unnecessary replies.