Hi, i’m trying to make it so that if the player has the InRange tag and clicks anywhere on screen, a row of Lasers will be destroyed. Here is my code
local handle = script.Parent:WaitForChild("Handle")
script.Parent.Click.OnServerEvent:Connect(function(plr,target)
local Map = game.Workspace:FindFirstChild("Map")
local LaserRoom2 = Map:FindFirstChild("LaserRoom2")
local Player = game:GetService("Players")
if Player:FindFirstChild("InRange") then
for i, v in pairs(LaserRoom2.Lazers:GetChildren()) do
if v:IsA("BasePart") and v.Name == "Lazer" then
v.Destroy()
end
end
end
end)
What do you mean by Tag? What kind of data is it? BoolValue, StringValue, IntValue, a Folder? We need to know more about the InRange Instance… Is it from the CollectionService? How are we suppose to guess.
Okay add some debug print statements real quick like this.
if plr:FindFirstChild("InRange") then
print("case 1")
for i, v in pairs(LaserRoom2.Lazers:GetChildren()) do
if v:IsA("BasePart") and v.Name == "Lazer" then
print("case 2")
v.Destroy()
end
end
end