Hello, i’ve made a plot system with ownership, everything else works but not the teleporting, no errors in outputs or yellow warnings, if u have any clue whats going on please let me know. (MODULE SCRIPT) (SERVERSCRIPTSERVICE)
Function that handles teleporting:
function PlotService:TeleportToPlot(player)
local plot = self:GetPlot(player)
if plot then
local spawn = plot:FindFirstChild("SpawnLocation")
if spawn and player.Character and player.Character.PrimaryPart then
player.Character:SetPrimaryPartCFrame(spawn.CFrame + Vector3.new(0,5,0))
end
end
end
Full module script:
local PlotsFolder = workspace:WaitForChild("Aquariums")
local PlotService = {}
local plotOwners = {}
local FORCE_ASSIGN = false
local FORCED_PLOT_NAME = "Plot1"
function PlotService:GetPlotOwners()
return plotOwners
end
function PlotService:GetPlot(player)
for plot, owner in pairs(plotOwners) do
if owner == player then
return plot
end
end
return nil
end
function PlotService:AssignPlot(player)
if FORCE_ASSIGN then
local forcePlot = PlotsFolder:FindFirstChild(FORCED_PLOT_NAME)
if forcePlot then
for p, owner in pairs(plotOwners) do
if owner == player or p == forcePlot then
self:FreePlot(owner)
end
end
plotOwners[forcePlot] = player
local ownerTag = forcePlot:FindFirstChild("Owner") or Instance.new("ObjectValue")
ownerTag.Name = "Owner"
ownerTag.Value = player
ownerTag.Parent = forcePlot
local signGui = forcePlot:FindFirstChild("Sign") and forcePlot.Sign:FindFirstChildWhichIsA("SurfaceGui")
local label = signGui and signGui:FindFirstChildWhichIsA("TextLabel")
if label then label.Text = player.Name end
if player.Character then
player.Character:WaitForChild("HumanoidRootPart", 3)
self:TeleportToPlot(player)
end
player.CharacterAdded:Connect(function()
self:TeleportToPlot(player)
end)
return forcePlot
end
end
for _, plot in ipairs(PlotsFolder:GetChildren()) do
if not plotOwners[plot] then
plotOwners[plot] = player
local ownerTag = plot:FindFirstChild("Owner") or Instance.new("ObjectValue")
ownerTag.Name = "Owner"
ownerTag.Value = player
ownerTag.Parent = plot
local signGui = plot:FindFirstChild("Sign") and plot.Sign:FindFirstChildWhichIsA("SurfaceGui")
local label = signGui and signGui:FindFirstChildWhichIsA("TextLabel")
if label then label.Text = player.Name end
if player.Character then
player.Character:WaitForChild("HumanoidRootPart", 3)
self:TeleportToPlot(player)
end
player.CharacterAdded:Connect(function()
self:TeleportToPlot(player)
end)
return plot
end
end
return nil
end
function PlotService:TeleportToPlot(player)
local plot = self:GetPlot(player)
if plot then
local spawn = plot:FindFirstChild("SpawnLocation")
if spawn and player.Character and player.Character.PrimaryPart then
player.Character:SetPrimaryPartCFrame(spawn.CFrame + Vector3.new(0,5,0))
end
end
end
function PlotService:FreePlot(player)
for plot, owner in pairs(plotOwners) do
if owner == player then
plotOwners[plot] = nil
local ownerTag = plot:FindFirstChild("Owner")
if ownerTag then ownerTag:Destroy() end
local signGui = plot:FindFirstChild("Sign") and plot.Sign:FindFirstChildWhichIsA("SurfaceGui")
local label = signGui and signGui:FindFirstChildWhichIsA("TextLabel")
if label then label.Text = "No one" end
return true
end
end
return false
end
return PlotService