Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do you delete instances with RemoteFunctions?

Asked by
y3_th 176
7 years ago

For some reason, there is a button in a SurfaceGUI that cannot be deleted across the entire server. This GUI is supposed to be in PlayerGUI, and I have implemented everything successfully except for this feature that will delete a button on the GUI. Using RemoteFunctions seems to be the best option, for now.

1--localScript
2 
3local requestMPG = game.ReplicatedStorage:WaitForChild("RequestDeleteMPG")
4 
5script.Parent.MouseButton1Down:Connect(function()
6    game.Players.LocalPlayer.Character.MPGA.Disabled = false
7 
8    local deletion = requestMPG:InvokeServer()
9end)
01--script
02 
03local replicatedStorage = game:GetService("ReplicatedStorage")
04 
05local deleteMPG = Instance.new("RemoteFunction")
06deleteMPG.Parent = replicatedStorage
07deleteMPG.Name = "DeleteMPGRequest"
08 
09function delete(player)
10    print(player .. "has chosen MPG!")
11 
12    for i, v in pairs(game.Players:GetPlayers()) do
13        v.PlayerGui.SurfaceGui.screen.grid.tealGreen:Destroy()
14    end
15end
16 
17deleteMPG.OnServerInvoke = delete
0
GUIs should be local only the server should not be deleteing GUIs for each player. This should be done in the local script User#5423 17 — 7y

Answer this question