How do you delete instances with RemoteFunctions?
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.
3 | local requestMPG = game.ReplicatedStorage:WaitForChild( "RequestDeleteMPG" ) |
5 | script.Parent.MouseButton 1 Down:Connect( function () |
6 | game.Players.LocalPlayer.Character.MPGA.Disabled = false |
8 | local deletion = requestMPG:InvokeServer() |
03 | local replicatedStorage = game:GetService( "ReplicatedStorage" ) |
05 | local deleteMPG = Instance.new( "RemoteFunction" ) |
06 | deleteMPG.Parent = replicatedStorage |
07 | deleteMPG.Name = "DeleteMPGRequest" |
09 | function delete(player) |
10 | print (player .. "has chosen MPG!" ) |
12 | for i, v in pairs (game.Players:GetPlayers()) do |
13 | v.PlayerGui.SurfaceGui.screen.grid.tealGreen:Destroy() |
17 | deleteMPG.OnServerInvoke = delete |