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
6 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.

--localScript

local requestMPG = game.ReplicatedStorage:WaitForChild("RequestDeleteMPG")

script.Parent.MouseButton1Down:Connect(function()
    game.Players.LocalPlayer.Character.MPGA.Disabled = false

    local deletion = requestMPG:InvokeServer()
end)
--script

local replicatedStorage = game:GetService("ReplicatedStorage")

local deleteMPG = Instance.new("RemoteFunction")
deleteMPG.Parent = replicatedStorage
deleteMPG.Name = "DeleteMPGRequest"

function delete(player)
    print(player .. "has chosen MPG!")

    for i, v in pairs(game.Players:GetPlayers()) do
        v.PlayerGui.SurfaceGui.screen.grid.tealGreen:Destroy()
    end
end

deleteMPG.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 — 6y

Answer this question