Sorry Everyone for wasting your time helping me Out, I will Look into it later on I think @ethamcker is right With Remote events.
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```
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()
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