Created
June 1, 2025 15:28
-
-
Save MajorTal/39e6167c3b3aedb1be68a5bb5061aa49 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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