Skip to content

Instantly share code, notes, and snippets.

@MajorTal
Created June 1, 2025 15:28
Show Gist options
  • Save MajorTal/39e6167c3b3aedb1be68a5bb5061aa49 to your computer and use it in GitHub Desktop.
Save MajorTal/39e6167c3b3aedb1be68a5bb5061aa49 to your computer and use it in GitHub Desktop.
local tool = script.Parent
local deleteRequest = tool:WaitForChild("DeleteRequest")
local function poleBelongsToPlayerRoom(pole, player)
local roomName = player:GetAttribute("Room")
local playerRoom = workspace.PlayerRooms:FindFirstChild(roomName)
return playerRoom and pole:IsDescendantOf(playerRoom)
end
deleteRequest.OnServerEvent:Connect(function(player, targetPole)
if targetPole and targetPole:IsA("BasePart") then
if poleBelongsToPlayerRoom(targetPole, player) then
print("Deleting pole:", targetPole.Name, "for player:", player.Name)
targetPole:Destroy()
else
warn("Player", player.Name, "attempted to delete a pole outside their room.")
end
end
end)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment