Thank you For your time and afford to solve my problem I appreciate your help any help.
hi I wanna have a script that destroys all individual bricks when clicked on that brick this is what i have i put into every brick in the world a click detector then loop through those click detectors for a click
for i,clickdetectors in pairs(clicktest) do print("hhh") clickdetectors.RightMouseClick:connect(function() deleteevent:FireServer(clickdetectors.Parent) print("hit") end) end
thanks, I really appreciate your help and your knowledge thanks.
You can't use for loops with click detectors, instead paste this script into every click detector
clickdetector.MouseClick:Connect(function() -- Change clickdetector to the path of the click detector, e.g if you have the script inside the click detector it would be script.Parent.MouseClick etc. etc. script.Parent.Parent:Destroy() -- Assuming the click detector is in a brick / part and the script is in the click detector
You also don't need a remote event, do all this in a server script!
If I helped please accept this answer!
This, with a cool statement.
--Server script local Clicked = false for i,clickdetector in pairs(clicktest) do print("Index:" .. i .. " is listening...") local Listener = clickdetector.MouseClick:connect(function() if Clicked == false then deleteevent:FireServer() print("hit") Clicked = true else Listener:Disconnect() end end) end ------Server script inside the Delete event local event = script.Parent local MultiplePartModel--You know local signal = event.OnServerEvent:Connect(function(plr) MultiplePartModel:Destroy() print("Destroyed.") end)
or this script which didn't modify the clickdetectors.Parent
part.
--Server script SECOND CHOICE, MIGHT ERROR local Clicked = false for i,clickdetector in pairs(clicktest) do print("Index:" .. i .. " is listening...") local Listener = clickdetector.MouseClick:connect(function() if Clicked == false then deleteevent:FireServer(clickdetector.Parent) print("hit") Clicked = true else Listener:Disconnect() end end) end ------Server script inside the Delete event local event = script.Parent local signal = event.OnServerEvent:Connect(function(plr,model) model.Parent:Destroy() print("Destroyed.") end)