Player's Position Changing Won't Work

I am making a comedy game and at the start of the game, a Dummy plays in a cutscene and wakes up.
Once it wakes up, since the Player isn’t the Dummy, the Player should change position(teleport) and stay in front of the bed.

I have a script which changes player’s Camera settings and when the player changes it’s position the Camera breaks, the Camera Offset breaks and the player movement breaks as well.

Unfortunately my file size was to big so I had to paste in the link.

This is what happens without the Position changing:
https://1drv.ms/v/s!AqC33HMFxhmCjigAVMcMojjvip4Y?e=B4EcE2

And this is what happens with the Position changing:
https://1drv.ms/v/s!AqC33HMFxhmCjilRiCrIGjc4lcRO?e=AvuhiP

I tried making a player transparent instead of him changing it’s position and I tried to use Character.HumanoidRootPart.Position = Vector3.new(0, 0, 0)
instead of
Character.HumanoidRootPart.Position = game.Workspace.RoomPart.Position

Here is a picture of my Explorer:
FirstPersonCamera - Roblox Studio 11_7_2021 2_22_37 PM (2)

This is the FirstPersonCamera script in which I’m trying to make it so whenever a player presses the Play button, the game waits until the cutscene ends and changes Player’s Camera:


wait(10)

local player = game.Players.LocalPlayer
local character = player.Character
local humanoid = character.Humanoid
local camera = game.Workspace.CurrentCamera

player.CameraMaxZoomDistance = 0.5
camera.FieldOfView = 80
humanoid.CameraOffset = Vector3.new(0, 0.5, -1.5)

for childIndex, child in pairs(character:GetChildren()) do
	if child:IsA("BasePart") and child.Name ~= "Head" then

		child:GetPropertyChangedSignal("LocalTransparencyModifier"):Connect(function(plr)
			child.LocalTransparencyModifier = child.Transparency
		end)

		child.LocalTransparencyModifier = child.Transparency

	end
	end
	end)

This is the WakingUpCutscene script:


	wait(0.1)

	local camera = game.Workspace.camera2
	local cam = game.Workspace.CurrentCamera
	local player = game.Players.LocalPlayer

	cam.CameraType = Enum.CameraType.Scriptable
	local pos = Vector3.new(-584, 11.702, -65.6)
	local LookAt = Vector3.new(-590.5, 6.302, -60.5)
	local camCFrame = CFrame.new(pos, LookAt)
	cam.CFrame = camCFrame

	wait(7)

	local pos = Vector3.new(-587, 7.702, -60)
	local LookAt = Vector3.new(-576.537, 5.102, -59.588)
	local camCFrame = CFrame.new(pos, LookAt)
	cam.CFrame = camCFrame

	wait(3)

	cam.CameraType = Enum.CameraType.Custom

end)

And finally this is the RoomPositionScript:

local Player = Players.LocalPlayer
local Character = Player.Character

script.Parent.MouseButton1Click:Connect(function(Player)
	wait(10)
	Character.HumanoidRootPart.Position = Vector3.new(-585, 4.102, -60)
end)```
2 Likes

You need to change the character’s position on a server script and not a local script. Also, instead of changing the position you should do
Character:SetPrimaryPartCFrame(Vector3.new(-585, 4.102, -60))

1 Like

I tried doing it but it unfortunately didn’t work. I’m getting an error saying:
Players.morisanero.PlayerGui.ScreenGui.Frame.TextButton.Script:3: attempt to index nil with ‘Character’

It worked for me without a RemoteEvent or Server Script

You just need to change Character.HumanoidRootPart.Position = Vector3.new(-585, 4.102, -60) to workspace:WaitForChild(Player.Name):WaitForChild("HumanoidRootPart").CFrame = CFrame.new(-585, 4.102, -60)

1 Like

Character isn’t part of the TextButton. You get the character from player.Character

1 Like

I tried doing this as well but I keep receiving this error:
Players.morisanero.PlayerGui.ScreenGui.Frame.TextButton.LocalScript:7: attempt to index nil with ‘Name’ even though it’s a local script and Player is defiened.

I tried this but I’m still getting the same error. Also I tried to define both player and character too but nothing has changed.

Can you show the new script?


1 Like

Try changing the whole script to this:

local Player = game.Players.LocalPlayer

script.Parent.MouseButton1Click:Connect(function()

wait(10)

workspace:WaitForChild(Player.Name):WaitForChild("HumanoidRootPart").CFrame = CFrame.new(-585, 4.102, -60)

end)
1 Like

I tried both:

local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local Character = Player.Character

script.Parent.MouseButton1Click:Connect(function(Player)
	wait(10)
	Player.Character:SetPrimaryPartCFrame(Vector3.new(-585, 4.102, -60))
end)

and

script.Parent.MouseButton1Click:Connect(function(Player)

wait(10)

game.Players.LocalPlayer.Character:SetPrimaryPartCFrame(Vector3.new(-585, 4.102, -60))

end)

This script worked! Thank you both for helping me and putting effort into this!

No problem. I’m glad that it helped :slight_smile:

1 Like
local Players = game:GetService("Players")
local Player = Players.LocalPlayer or Players.PlayerAdded:Wait()
local Character = Player.Character or Player.CharacterAdded:Wait()

script.Parent.MouseButton1Click:Connect(function()
	task.wait(10)
	Character:SetPrimaryPartCFrame(CFrame.new(-585, 4.102, -60))
end)

A little fix & just going to suggest a few things, I’ve added waits to the player & character being added (this is to ensure the script doesn’t execute before those instance have been loaded), “wait()” has been replaced by “task.wait()” and is thus outdated, you should opt to use task.wait() from now on as it is more accurate, finally SetPrimaryPartCFrame would’ve worked but the user who provided that solution mistakenly passed a Vector3 value as an argument instead of a CFrame value which is required. SetPrimaryPartCFrame is more favorable to use as it works better with custom character models. Also because you already have the “Character” defined in the script you can fetch it by simply referencing “Character” instead of “Player.Character” as the previously offered solutions did.

1 Like