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

ScreenGui doesn't get removed when you click a button?

Asked by 5 years ago
Edited 5 years ago

Hello! I am currently fixing the Welcome to the Town of Robloxia game by 1dev2, since Roblox has made changes to their scripting, and I've run into a little problem. This code:

script.Parent.MouseButton1Click:Connect(function()
    local t = game.Teams[script.Parent.Text]
    script.Parent.Parent.Parent.Parent.Parent.Parent.TeamColor = t.TeamColor
    local spawns = game.Workspace.SpawnLocations:GetChildren()
    for i=1, #spawns do
        if spawns[i].TeamColor == t.TeamColor then
            script.Parent.Parent.Parent.Parent.Parent.Parent.Character:MoveTo(spawns[i].Position + Vector3.new(0,10,0))
        end
    end
    script.Parent.Parent.Parent:Remove()
end)

Everything works fine, apart from line 10. The Background doesn't get removed. Everything else in that block of code works. It's in a LocalScript, in a button. What's suppose to happen is, when you click the button, the black background is suppose to dissapear.

Any help is greatly appreciated. :)

0
Any errors? Or a screenshot of the hierarchy? Because Idk what's script.Parent, or script.Parent.Parent or script.Parent.Parent.Parent in your game Amiaa16 3227 — 5y
2
:Remove() is deprecated, use :Destroy() instead. Also, maybe set the background transparency to 1, or set the black background's parent to a new parent, for example a folder in ReplicatedStorage ScrubSadmir 200 — 5y
0
What @ScrubSadmir said! XviperIink 428 — 5y
0
^^ That should fix it. Lugical 425 — 5y
0
Also, really, don't use script.Parent.Parent.Parent.Parent.Parent.Parent. Use game.Players.LocalPlayer... User#24403 69 — 5y

Answer this question