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

Why won't my gui work right?

Asked by 8 years ago

I have a textbutton in my gui and I named them specially. The gui is called clean and the button is called serverclean1.

I tried the following code:

game.StarterGui.clean.serverclean1

regenallcars=game.workspace.racercars racercars: remove()

--note: be sure to tap the regens first.

--I'm definately an idiot at scripting.

2 answers

Log in to vote
0
Answered by 8 years ago

Make sure that if you're doing this, if it's a server script make sure that

regenallcars=game.workspace.racercars racercars: remove()

should be

local regenallcars=game.workspace.racercars racercars: remove()

When local is added it makes sure that the gui is run all over the server, and not just for one player.

0
Ok, thanks! :) asf2424 0 — 8y
0
The "racercars: remove()" part is highlighted in blue, did it break partially? asf2424 0 — 8y
Ad
Log in to vote
0
Answered by
Wutras 294 Moderation Voter
8 years ago

This script has too many mistakes in it to work properly and would have to be totally rewritten to work. I'd propose to learn the basics of scripting at this website: http://wiki.roblox.com/index.php?title=Special:RobloxLandingPage But I guess that the script is supposed to clean the workspace so I'll do this for you and explain everything.

for _, player in pairs(game.Players:GetPlayers()) do -- This is to do the same thing with all the players.
    player.PlayerGui.clean.serverclean1.MouseButton1Click:connect(function() -- This is an event that's being called when the TextButton is pressed.
        safetycopies = {} -- This is an empty table.
        for _, tobecopied in pairs(workspace:GetChildren()) do
            if not tobecopied:IsA("Terrain") and not tobecopied:IsA("Camera") then -- This checks whether the thing in the workspace is Terrain or a Camera. If it is not then the script will do the next step.
                table.insert(safetycopies, tobecopied:Clone()) -- This adds the clone of the thing to the table named safetycopies
            end
        end
        for _, toberemoved in pairs(workspace:GetChildren()) do
            if not toberemoved:IsA("Terrain") and not toberemoved:IsA("Camera") then
                toberemoved:Destroy() -- This cuts all connections and totally destroys the thing.
            end
        end
        for _, tobeplaced in pairs(safetycopies) do
            tobeplaced.Parent = workspace -- This adds the copied thing to the workspace.
        end
    end)
end
0
Tell me if you want something changed. Wutras 294 — 8y

Answer this question