#script broken again for some reason

1 messages · Page 1 of 1 (latest)

hollow needle
#

First script: assigns player an id through attributes

local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local MAX_PLOTS = 10

local assignPlotEvent = ReplicatedStorage:WaitForChild("AssignPlotIDEvent")

local assignedPlots = {}

local playerPlots = {}

local function findAvailablePlot()
for i = 1, MAX_PLOTS do
if not assignedPlots[i] then
return i
end
end
return nil
end

local function onPlayerAdded(player)

if playerPlots[player] then
    
    assignPlotEvent:FireClient(player, playerPlots[player])
    print(player.Name .. " already has Plot ID: " .. playerPlots[player])
    return
end

local assignedPlotId = findAvailablePlot()

if assignedPlotId then
    print("Assigning Plot ID " .. assignedPlotId .. " to player " .. player.Name)
    assignedPlots[assignedPlotId] = player
    playerPlots[player] = assignedPlotId


    player:SetAttribute("PlotID", assignedPlotId)

    
    assignPlotEvent:FireClient(player, assignedPlotId)
end

end

local function onPlayerRemoving(player)
local plotId = playerPlots[player]
if plotId then
print("Releasing Plot ID " .. plotId .. " from player " .. player.Name)
assignedPlots[plotId] = nil
playerPlots[player] = nil

    end
end

Players.PlayerAdded:Connect(onPlayerAdded)
Players.PlayerRemoving:Connect(onPlayerRemoving)

for _, player in Players:GetPlayers() do
task.spawn(onPlayerAdded, player)
end

print("PlotAssigner Booted :P")

Second script: determines if plotID matches with the name of a part in a folder in Workspace and tries to turn off the CanCollide property if it matches.

idle fern
hollow needle
#

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local Workspace = game:GetService("Workspace")

local LocalPlayer = Players.LocalPlayer
local assignPlotEvent = ReplicatedStorage:WaitForChild("AssignPlotIDEvent")
local plotsFolder = Workspace:WaitForChild("Plots")

local myPlotId = nil

local function updatePlotCollisions()
if not plotsFolder then
warn("Plots folder not found!")
return
end

for _, plotZone in plotsFolder:GetChildren() do
    if plotZone:IsA("BasePart") then
        local success, zoneId = pcall(function()
            return tonumber(plotZone.Name)
        end)
        if success and zoneId then
            if myPlotId and zoneId == myPlotId then
                plotZone.CanCollide = false
            else
                plotZone.CanCollide = true
            end
        end
    end
end

end

assignPlotEvent.OnClientEvent:Connect(function(assignedId)
print("Received Plot ID:", assignedId)
myPlotId = assignedId
updatePlotCollisions()
end)

updatePlotCollisions()

print("PlotZoneHandler Booted :P")

#

i need help :(

#

i dont get it

#

it makes sense

#

it checks if the plotID matches with the zoneID

next hull
hollow needle
#

i require assistance at this moment !!

idle fern
#

s0 activities

hollow needle