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 ReplicatedStorage = game:GetService("ReplicatedStorage") | |
local ServerStorage = game:GetService("ServerStorage") | |
local ShopItems = require(ServerStorage.ShopItems) | |
local buyItemEvent = ReplicatedStorage:WaitForChild("BuyItemEvent") | |
buyItemEvent.OnServerEvent:Connect(function(player, itemType) | |
local itemDef = ShopItems[itemType] | |
if not itemDef then | |
warn("Unknown item:", itemType) |
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 event = game.ReplicatedStorage:WaitForChild("GlobalPlaceRequest") | |
local itemType = tool:WaitForChild("ItemType").Value | |
local player = game.Players.LocalPlayer | |
local mouse = player:GetMouse() | |
tool.Activated:Connect(function() | |
if mouse.Target then | |
local position = mouse.Hit.p | |
event:FireServer(itemType, position) |
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 ReplicatedStorage = game:GetService("ReplicatedStorage") | |
local ServerStorage = game:GetService("ServerStorage") | |
local ShopItems = require(ServerStorage.ShopItems) | |
local function snapToGrid(position, gridSize) | |
return Vector3.new( | |
math.floor(position.X / gridSize + 0.5) * gridSize, | |
position.Y, | |
math.floor(position.Z / gridSize + 0.5) * gridSize | |
) |
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 function savePoles(player) | |
local roomName = player:GetAttribute("Room") | |
local room = workspace.PlayerRooms:FindFirstChild(roomName) | |
if not room then return end | |
local polesData = { | |
poles = {}, | |
roomCenter = { | |
x = room.Position.X, | |
y = room.Position.Y, |
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 function loadPoles(player) | |
local previousDataSuccess, polesData = pcall(function() | |
return poleDataStore:GetAsync(player.UserId) | |
end) | |
if not previousDataSuccess or not polesData then | |
warn("No previous poles data found for player:", player.Name) | |
return | |
end |
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 DataStoreService = game:GetService("DataStoreService") | |
local poleDataStore = DataStoreService:GetDataStore("PolePlacementData") | |
local Players = game:GetService("Players") | |
local GRID_SIZE = 4 -- Same grid size you used earlier | |
-- Helper to snap positions | |
local function snapToGrid(position) | |
return Vector3.new( |
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 function restackPolesAtPosition(deletedPolePosition, room) | |
local polesAtPos = {} | |
-- Find poles at same X,Z position | |
for _, pole in ipairs(room:GetChildren()) do | |
if pole:IsA("BasePart") then | |
if math.abs(pole.Position.X - deletedPolePosition.X) < 0.1 and math.abs(pole.Position.Z - deletedPolePosition.Z) < 0.1 then | |
table.insert(polesAtPos, pole) | |
end | |
end |
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) |
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 player = game.Players.LocalPlayer | |
local mouse = player:GetMouse() | |
tool.Activated:Connect(function() | |
if mouse.Target and mouse.Target:IsA("BasePart") then | |
deleteRequest:FireServer(mouse.Target) | |
end | |
end) |
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 placeRequest = tool:WaitForChild("PlaceRequest") | |
local GRID_SIZE = 4 -- Grid snapping size | |
local function snapToGrid(position, gridSize) | |
return Vector3.new( | |
math.floor(position.X / gridSize + 0.5) * gridSize, | |
position.Y, | |
math.floor(position.Z / gridSize + 0.5) * gridSize |
NewerOlder