Im trying to move a player, so im using a BodyPosition, but when i use it, it does not insert a BodyPosition. There are no errors, so I do not understand why it does not work. Here is my script.
local head = player:WaitForChild('Head') v = true print("Fall mode") workspace.CurrentCamera.CameraType = "Custom" Player:LoadCharacter() local character = Player.Character if not character or not character.Parent then character = Player.CharacterAdded:wait() end print("tp") local Force = Instance.new("BodyPosition") Force.Parent = character:WaitForChild("Head") head:WaitForChild("BodyPosition").Position.X = Player.PlayerGui.FreeCam.PlaceHolder.Value.X head:WaitForChild("BodyPosition").Position.Y = Player.PlayerGui.FreeCam.PlaceHolder.Value.Y head:WaitForChild("BodyPosition").Position.Z = Player.PlayerGui.FreeCam.PlaceHolder.Value.Z print("done") repeat wait(1) until math.floor(head.Position.X) == math.floor(Player.PlayerGui.FreeCam.PlaceHolder.Value.X) and math.floor(head.Position.Y) ==math.floor(Player.PlayerGui.FreeCam.PlaceHolder.Value.Y) and math.floor(head.Position.Z) ==math.floor(Player.PlayerGui.FreeCam.PlaceHolder.Value.Z) --This gets the head's position and matching it with my value i want it to be. I'm using math.floor in case there are any decimals. wait(1) print('Done!') head.BodyPosition:Destroy()
In case you are wondering, Player is already defined. It is the player in the players list. This is in a server script if you need to know for something I don't already know.
CurrentCamera
is not accessible with a server script.
It will be the base camera clip in the game, not the player camera.
Also, there are a lot more efficient ways to spawn and edit the body force.
So I would change this to a local script and edit how you spawn in the force (although it should work, its not very clean and efficient)
local head = player:WaitForChild('Head') v = true print("Fall mode") workspace.CurrentCamera.CameraType = "Custom" Player:LoadCharacter() local character = Player.Character if not character or not character.Parent then character = Player.CharacterAdded:wait() end print("tp") Force = Instance.new("BodyPosition") -- dont use a parent modifier and give it a delay to enter the game to avoid load-in lagg. Force.Position = Vector3.new(Player.PlayerGui.FreeCam.PlaceHolder.Value) Force.Parent = character:WaitForChild("Head") repeat wait(1) until math.floor(head.Position.X) ==math.floor(Player.PlayerGui.FreeCam.PlaceHolder.Value.X) and math.floor(head.Position.Y) ==math.floor(Player.PlayerGui.FreeCam.PlaceHolder.Value.Y) and math.floor(head.Position.Z) ==math.floor(Player.PlayerGui.FreeCam.PlaceHolder.Value.Z) --This gets the head's position and matching it with my value i want it to be. I'm using math.floor in case there are any decimals. wait(1) print('Done!') head.BodyPosition:Destroy()