Hi there!
So… I’m working on a character customization + spawn system, and whenever i rejoin the game, and there are still players in the game, they are in the air for some reason. To them it looks like they are still on the ground and there’s nothing wrong for them.
They also move really fast trough the air when they are walking.
Is this a studio bug or something? I am willing to show the script but they are very long, and i only set the HumanoidRootParts position 2 studs above a spawn, on the server.
Thanks!
`
local Characters = {}
local DataStore = game:GetService("DataStoreService"):GetDataStore("LastCharacter")
function Characters.UpdateCharacter(plr, name)
local characters = game.ReplicatedStorage.Characters
local char = plr.Character
plr.CharVal.Value = tostring(name)
if characters:FindFirstChild(name) then
local rig = characters[name]
plr.PlayerGui:WaitForChild("Customization").Main.Scrolling.Characters[name].Selected.Value = "true"
if name == "Versuft" then
char.Head.Transparency = 1
else
char.Head.Transparency = 0
end
local function weldtogether(x,y)
local weld = Instance.new("Weld")
weld.Part0 = x
weld.Part1 =y
local cj = CFrame.new(x.Position)
local c0 = x.CFrame:inverse()*cj
local c1 = y.CFrame:inverse()*cj
weld.C0 = c0
weld.C1 = c1
weld.Parent = x
end
if char:FindFirstChild("Head") then
if char.Head:FindFirstChildOfClass("Model") then
for a,b in pairs(char.Head:GetChildren()) do
if b:IsA("Model") then
char.Head:FindFirstChildOfClass("Model"):Destroy()
end
end
else
print(" ")
end
for i, v in pairs(rig.Helmet:GetChildren()) do
local helmet = v:Clone()
for _,m in pairs(helmet:GetChildren()) do
weldtogether(m, helmet.Middle)
m.Anchored = false
m.CanCollide = false
end
local weld = Instance.new("Weld")
weld.Part0 = helmet.Middle
weld.Part1 = char:FindFirstChild("Head")
weld.Parent = helmet.Middle
helmet.Parent = plr.Character.Head
end
end
if char:FindFirstChild("UpperTorso") then
if char.UpperTorso:FindFirstChildOfClass("Model") then
for a, b in pairs(char.UpperTorso:GetChildren()) do
if b:IsA("Model") then
char.UpperTorso:FindFirstChildOfClass("Model"):Destroy()
end
end
else
print(" ")
end
for i, v in pairs(rig.Waist:GetChildren()) do
local accessory = v:Clone()
for _,m in pairs(accessory:GetChildren()) do
weldtogether(m, accessory.Middle)
m.Anchored = false
m.CanCollide = false
end
local weld = Instance.new("Weld")
weld.Part0 = accessory.Middle
weld.Part1 = char:FindFirstChild("UpperTorso")
weld.Parent = accessory.Middle
accessory.Parent = plr.Character.UpperTorso
end
end
local shirt = rig.Shirt.ShirtTemplate
local pants = rig.Pants.PantsTemplate
char:WaitForChild("Pants").PantsTemplate = pants
char.Shirt.ShirtTemplate = shirt
char.Head.face.Texture = rig.Face.Texture
if char:FindFirstChild("BodyColors") then
char.BodyColors:Destroy()
rig.BodyColors:Clone().Parent = char
end
end
end
function Characters.CreatePlayerSpawn(plr)
local spawns = workspace.Spawns
local SpawnVal = plr.SpawnVal
if SpawnVal.Value ~= "No Spawn" then
return "Player already has a spawn."
elseif SpawnVal.Value == "No Spawn" then
for _, v in pairs(spawns:GetChildren()) do
if v.Occupied.Value ~= true then
v.Occupied.Value = true
plr.SpawnVal.Value = v.Name
print(plr.SpawnVal.Value)
return
end
end
end
end
function Characters.RemovePlayerSpawn(plr)
local spawns = workspace.Spawns
local SpawnVal = plr.SpawnVal
spawns[SpawnVal.Value].Occupied.Value = false
print("Removed.")
end
function Characters.PlacePlayer(plr, character)
local spawns = workspace.Spawns
local SpawnVal = plr.SpawnVal
wait(.5)
local PlayersSpawn = spawns:FindFirstChild(SpawnVal.Value)
character.HumanoidRootPart.Position = PlayersSpawn.Position + Vector3.new(0,2,0)
end
function Characters.SaveCharacter(plr)
DataStore:SetAsync(plr.UserId, plr.CharVal.Value)
print("Succesfully saved the character.")
end
function Characters.LoadCharacter(plr)
if DataStore:GetAsync(plr.UserId) == nil then
return "Le Kert"
elseif DataStore:GetAsync(plr.UserId) ~= nil then
plr.PlayerGui:WaitForChild("Customization").Main.Play.Text = "PLAY"
return DataStore:GetAsync(plr.UserId)
else
warn("Something went wrong when loading the character.")
end
end
return Characters
`