Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do I use a gui and a localscript to hide trees?

I wanna make a lag button, so I made a gui with a localscript to be able to hide a certain amount of trees. I don't know how to make the script. Can someone help me with the script?

2 comments

0

erm, this ain't a website where you simply ask for a script and wait for people to do all the work. You have to try to solve your questions yourself first before you ask here.

0

buddy i have thats why im asking

2 answers

✓ Accepted answer

You can make the certain trees as a model, and using ipairs loop or for loop and make them invisible. Well, you also can use for loop but I do not recommend because for loop does not know the part names but ipairs loop does collecting instances while for loop is recommended for number usage.

Make the trees you want to hide on the model, and name the model anything if you want. But for my script, you need to name it ToggleTree.

local Trees = game.Workspace.ToggleTree
local HidingTrees = false
local debounce = false

if debounce == true then
for i, v in ipairs(Trees:GetChildren()) do
    debounce = true
    if HidingTrees == false then
    HidingTrees = true
    v.Transparency = 1
    v.CanCollide = false
    else
    HidingTrees = false
    v.Transparency = 0
    v.CanCollide = true
    end
    wait(1)
    debounce = false
    end
end

Note: some LocalScript does not work in ServerScriptService or Workspace... Incase your LocalScript works make them inside StarterPack or StarterGui.

Also, this is just a sample, you will still need to make it your own

2 comments

0

So, if I replace that with delete trees: would it still work?

0

Variables name are not important, it's just for you to know what you are doing. For example, you are making a Murder Mystery game. You can name the murderer name "Innocent" and the innocent name as "Murderer". It still works the same if you understand what is going on with your script. But I don't recommend making random variables name script because? Don't be a stupid like me who did them in 2016

a very handy feature I would use in this case is CollectionService. this allows you to mark any physical game object with a tag and allows you to retrieve them easily. just select any tree you would like to omit and tag it with something like “high quality”. then, use collectionservice to retrieve these trees and set their transparency to 1 in a single loop when the user hits the button.

I advise you to look up how to use collectionservice yourself if you do not know already. the “tag editor” plugin makes it super easy. if you are still stuck, comment and I will edit in some code tomorrow :)

This discussion is preserved as it was. New answers, comments, and votes are closed.