What do you want to achieve? gates destroy when a player joins based on his Value
What is the issue? the gates dont destroy themselves
What solutions have you tried so far? i tried to use for loops but it didnt work
heres a part of the code which is supposed to destroy the gates on join
local player = game:GetService("Players").LocalPlayer
local gatesValue = player.Data:FindFirstChild("Gates")
local world = game:GetService("Workspace")
for i, v in pairs(world:GetDescendants()) do
if v.Name == "Gate"..tostring(gatesValue.Value <= gatesValue.Value) then
v:Destroy()
end
end
Why did you write this? tostring(gatesValue.Value <= gatesValue.Value) will always return the string "true" because obviously gatesValue.Value == gatesValue.Value is true, so you’re essentially checking if the gate is named "Gatetrue". Is that what your gates are named?
local player = game:GetService("Players").LocalPlayer
local gatesValue = player.Data:FindFirstChild("Gates")
local world = game:GetService("Workspace")
for i, v in pairs(world:GetDescendants()) do
if v.Name == "Gate1" or v.Name == "Gate2" then
v:Destroy()
end
end
Instead of just relying on the client to destroy the gate (as it could accidentally be brought back on the server), you could simply create a Collision Group for all players who are not permitted to pass the gate when their character loads.