so im making a script that when a player joins it teleports them to a specific plot of land where they build on.
i honestly suck at scripting so find mistakes.
local playerAmount = 0
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
game.Players.PlayerAdded:Connect(function(plr)
playerAmount = playerAmount + 1
end)
game.Players.PlayerRemoving:Connect(function(plr)
playerAmount = playerAmount - 1
end)
--Gets the island number for the player (Local Player Island)
local LPI = Instance.new('IntValue')
LPI.Value = playerAmount
LPI.Parent = game.Players.LocalPlayer
if LPI.Value == 1 then
local x, y, z = -2941, -5.5, -1659;
char:SetPrimaryPartCFrame(CFrame.new(x, y, z));
end

1 comment
Use data stores. https://developer.roblox.com/en-us/articles/Data-store