Need Help with this Local Script

Sorry Everyone for wasting your time helping me Out, I will Look into it later on I think @ethamcker is right With Remote events.

1 Like

Should it switch when anyone clicks it? If so you can just have one remote event and change the first line of the script from checking when a button is pressed to be connected to a remote event. You can also have a 3 line local script.

hold up if you wanted to clear it from everyoneā€™s screen you could create a folder with the name of the player then everything that they place is put inside the folder then check to see if it is in the folder something like this

whatever.MouseButton1Down:connect(function(plr)
local PlayerFolder = instance.new("folder") -- when cloning the trees put make a script to auto put them in this folder
PlayerFolder.parent = workspace
PlayerFolder.name = plr.localplayer.Name

if Tree.Parent == PlayerFolder then

GetChildren(PlayerFolder):Destroy
else 
whatever

      end)
end



sry for poor layout i kinda rushed this

local script:

script.Parent.MouseButton1Down:Connect(function()
  game.ReplicatedStorage:WaitForChild("TriggerRE"):FireServer()
end)

server script:

local event = Instance.new("RemoteEvent", game.ReplicatedStorage)
event.Name = "TriggerRE"
event.OnServerEvent:Connect(function()
  local trans = 1
  local collide = false
  script.Parent.MouseButton1Down:Connect(function()
    for i, v in pairs(game.Workspace.Vegetation:GetDescendants()) do if not v:IsA("BasePart") then continue end
      v.Transparency = trans
      v.CanCollide = collide
    end
    trans= math.abs(trans- 1)
    collide = not collide
  end)
end```
1 Like

This is true, but the instance stored in ReplicatedStorage in my script isnā€™t ever mentioned by name. tree's reference doesnā€™t change. If you were searching ReplicatedStorage on the server, though, I can see why this would be a problem (in only certain cases where you query ReplicatedStorageā€™s children (which I donā€™t recommend)).

If in some scenario you do need more organization you can use your folder mechanism, yes, or even store it in something other than ReplicatedStorage that isnā€™t replicated, like the player object in Players.

Disclaimer: I actually donā€™t fully know how the replication barrier works on ReplicatedStorage, so if Model also appears on the server that is my oversight, though I donā€™t think it will really matter unless you end up querying ReplicatedStorageā€™s children for some other reason. I will take note to research that myself at some point.

im a beginner dev so i dont rly know how replicated storage works this was the simplest way i could think of to avoid other people from deleting ur work lol

Itā€™s not complicated at all.

script.Parent.MouseButton1Click:Connect(function()

workspace.Vegetation:Destroy()

end)

If itā€™s a folder of trees then you can just do ClearAllChildren()

1 Like

yes but then anybody in the game would be able to clear other peoples builds

Then put the script in a LocalScript?

that would still allow another user to delete something that another user place even if it is just for them it still seems improper

1 Like