Hello, I currently have this script that is meant to detect what player pressed a GUI button, detect if a part of the same name as the player exists within a folder, and if true, destroy the part. My problem is that I wish to remove the part from the entire server, while this code (local script) only removes it from the client. If I attempt to do this via regular script, it does not work at all. How may I fix this and thank you.
script.Parent.MouseButton1Click:Connect(function(player)
for Index, Part in ipairs(workspace.Aircraft:GetDescendants()) do
if Part.Name == player.Name then
Part:Destroy()
end
end
end)
Just use Remote Event.
Make one and put it on Replicated Storage.
local RemoteEvent = game:GetService("ReplicatedStorage"):FindFirstChild("RemoteEvent")
script.Parent.MouseButton1Click:Connect(function(player)
for Index, Part in ipairs(workspace.Aircraft:GetDescendants()) do
if Part.Name == player.Name then
RemoteEvent:FireServer(Part)
end
end
end)
Then it calls the server, and you got to make a Server Script and write your part code deletion, just like this:
local RemoteEvent = game:GetService("ReplicatedStorage"):FindFirstChild("RemoteEvent")
RemoteEvent.OnServerEvent:Connect(function(PlayerClient, Part))
Part:Destroy()
end)
Learn more about events here, as they are pretty useful when it comes to scripting:
Iām guessing the problem is from the part variable.
It seems like the script hasnāt recognized that variable as PART very well.
Make sure that the variable is your part.
Double check it.
You sure that the parent of the script is a button?
Also try debugging with print(), so you could find out player nameā¦ part nameā¦ etc.
Print out those things, it might be helpful.
That could be solved by just adding some extra security statements when firing the part along with it.
Plus, nobody said this project he is working on is going on public so fast at first time.
They will add extra anti cheatsā¦ etc, once they are finished.
So what makes you worry about a non-finished script on a private game?
It looks a like a cake.
You got to make the cake first, make it EXIST.
Then you add extra things.
As the topic title said, it requires a help in part deletion, not security stuff.
I believe in the ALPHA version of the project, these bugs, lack of security should be checked.
So not really, it will be noticed.
We have to discuss what part of the script is his PROBLEM.
Not extra things.