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

Why is Destroy() not working after I clone a Folder?

Asked by 6 years ago

I am cloning this Folder full of TextLabels into a SurfaceGui. I have a button in the SurfaceGui to remove the Folder with "Destroy()". The Folder never removes when I click the button. (The game is FE)

Cloning Script: --This is a LocalScript

script.Parent.MouseButton1Click:Connect(function()
    script.Parent.Parent.Parent.Parent.ScreenGui.Frame.Visible = true
    wait(0.1)
    local order = game.Players.LocalPlayer.Backpack.Order:Clone()
    order.Parent = game.Workspace.OrderMachine.Order.SurfaceGui.Frame
end)

Destroy Script: --This is a Script

script.Parent.MouseButton1Click:Connect(function()
    script.Parent.Parent.Order:Destroy()
end)
2
Use a remote event to tell the server that the player has clicked the GuiButton. The server should handle destroying and cloning the objects. xPolarium 1388 — 6y
1
Cloning an instance on the client wont replicate to the server. xPolarium 1388 — 6y
0
Agreed RetroGalacticGamer 331 — 6y

1 answer

Log in to vote
1
Answered by 6 years ago
Edited 6 years ago

I think I know what it is. See, when you clone the folder with the localscript, only the client sees the folder, not the server. Therefore, when the server tries to destroy it, it can't even find it, so an error pops up. I think this is what you are doing wrong. And considering the game is FE, you have got a BIG problem. So I think you need to use a server script to clone it. I know this might seem hard to do, but you can use RemoteFunctions and RemoteEvents to make the server and client communicate. I bet you will find a way. If this isn't your problem and the server sees it, I don't know what to tell you.

0
Alright thank you, this has worked. I totally forgot about Client vs Server since it was cloning into workspace. Thanks for reminding me, lol. Asynchronize 16 — 6y
Ad

Answer this question