game.Players.PlayerAdded:Connect(function(player) local cPart = Instance.new("Part") cPart.Name = "cPart" cPart.Size = Vector3.new(5, 3, 0.2) cPart.Shape = Enum.PartType.Cylinder cPart.Transparency = 1 cPart.CanCollide = false cPart.Anchored = true player.CharacterAdded:Connect(function(char) cPart.Parent = char cPart.Position = char.HumanoidRootPart.Position - Vector3.new(0, 4, 0) local function weldBetween(a,b) local weld = Instance.new("ManualWeld", a) weld.Part0 = a weld.Part1 = b weld.C0 = a.CFrame:inverse() * b.CFrame return weld end local weld = weldBetween(char.HumanoidRootPart, cPart) cPart.Position = tileGrid:FindFirstChild("PlayerStart"..playerInt.Value).Position + Vector3.new(0,3,0) end)
So here I have a script which creates a "cPart" (Control Part) and welds it to the player's character for easy manipulation of the player's character. It starts by putting the cPart in the same position as the player's character, then welds the character and the part together, then it is supposed to teleport the cPart to the proper starting point. Problem is, this last step just doesn't work at all. In the game the characters are stuck floating where they spawned, welded to the cPart. How can I get the server to put the cParts in the correct position so everybody can see it? Thanks
EDIT: I included a print(cPart.Position) at the end of this script just to see what it would say, and the output says that the cPart's position is the same as the position of the "PlayerStart" part that I am attempting to teleport to, indicating that it teleported correctly. But in the game world, this clearly isn't true, it's just how I described above. This is extremely bizarre to me. Help?
if you want the same pos as HumanoidRootPart you have to call the Character first like
game.Players.PlayerAdded:Connect(function(player) local cPart = Instance.new("Part") cPart.Name = "cPart" cPart.Size = Vector3.new(5, 3, 0.2) cPart.Shape = Enum.PartType.Cylinder cPart.Transparency = 1 cPart.CanCollide = false cPart.Anchored = true player.CharacterAdded:Connect(function(char) cPart.Parent = char.Character cPart.Position = char.Character.HumanoidRootPart.Position - Vector3.new(0, 4, 0) local function weldBetween(a,b) local weld = Instance.new("ManualWeld", a) weld.Part0 = a weld.Part1 = b weld.C0 = a.CFrame:inverse() * b.CFrame return weld end local weld = weldBetween(char.HumanoidRootPart, cPart) cPart.Position = tileGrid:FindFirstChild("PlayerStart"..playerInt.Value).Position + Vector3.new(0,3,0) end)
and where is your first
game.Players.PlayerAdded:Connect(function(player)
ending