Changing to a specific camera stops player from moving

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    When the player is sent to the baseplate where they need to dodge bullets, I want the player to be able to move.

  2. What is the issue? Include screenshots / videos if possible!
    Whenever I change the camera (not teleport, not set walkspeed) to the camera that’s dirrected at the baseplate, the player can’t move

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I’ve tried changing my camera code. I wanted to see what happens if I set the camera to the camere I use during battle (not while the player is dodging) and setting my walkspeed to 20 there, and I am able to move.

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

The only time I’m able to move in my code is when I remove the line of code that changes my camera to “AttackCameraPart”. But when I replace it with “CameraPart”, I can move just fine?

CameraScript:

local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RunService = game:GetService("RunService")

local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoidRootPart = character:WaitForChild("HumanoidRootPart")

local CurrentCamera = workspace.CurrentCamera
local ChangeCamera = ReplicatedStorage.ChangeCamera

local RunStep = true

CurrentCamera.CameraSubject = humanoidRootPart
CurrentCamera.CameraType = Enum.CameraType.Attach

local function updateCamera()
	if RunStep then
		CurrentCamera.CFrame = CFrame.new(humanoidRootPart.Position) * CFrame.new(0, 15, 20) * CFrame.Angles(math.rad(-40), 0, 0)
	end
end

RunService.Stepped:Connect(updateCamera)

ChangeCamera.OnClientEvent:Connect(function(cameraName)
	if cameraName ~= "Player" then
		RunStep = false
		CurrentCamera.CameraType = Enum.CameraType.Scriptable
		CurrentCamera.CFrame = workspace:WaitForChild(cameraName).CFrame
	else
		RunStep = true
		CurrentCamera.CameraType = Enum.CameraType.Attach
	end
end)

Code where I change camera and walkspeed:

Humanoid.WalkSpeed = 20
task.wait(1)
ChangeCamera:FireClient(player, "AttackCameraPart")

local turnLength = 10

IdleAnim:Stop()
MagicAnim:Stop()

if player.Character:FindFirstChild("ClassicSword") then
	player.Character.ClassicSword.Parent = player.Backpack
end
				
player.Character:MoveTo(workspace.BattleBaseplate.Position + Vector3.new(0, 3, 0))

Here’s a video of it:
(When I’m teleported back to where I choose something on my turn, I’m using the same camerascript and using “CameraPart” rather than “AttackCameraPart”)

3 Likes

I think this can help ya.

Use WaitForChild: Ensure that “AttackCameraPart” exists in the workspace before attempting to set the camera to its position. You can use WaitForChild to make sure the part is available.

task.wait(1)

local AttackCameraPart = workspace:WaitForChild("AttackCameraPart")
ChangeCamera:FireClient(player, AttackCameraPart)

Adjust Camera Position: Modify the camera position to avoid any potential conflicts with player movement. Experiment with different offsets and angles to find a suitable configuration.

task.wait(1)

local AttackCameraPart = workspace:WaitForChild("AttackCameraPart")
ChangeCamera:FireClient(player, AttackCameraPart)

local turnLength = 10

IdleAnim:Stop()
MagicAnim:Stop()

if player.Character:FindFirstChild("ClassicSword") then
    player.Character.ClassicSword.Parent = player.Backpack
end

player.Character:MoveTo(AttackCameraPart.Position + Vector3.new(0, 3, 0))
  1. Check for Animation Events: If there are animations playing, ensure that they do not interfere with the player’s movement. Check for animation events or loops that might affect the ability to move.
  2. Debugging: Add print statements to output relevant information during script execution. This can help identify any unexpected behavior or errors.
task.wait(1)
print("Changing camera...")

local AttackCameraPart = workspace:WaitForChild("AttackCameraPart")
ChangeCamera:FireClient(player, AttackCameraPart)

print("Camera changed. Moving player...")

local turnLength = 10

IdleAnim:Stop()
MagicAnim:Stop()

if player.Character:FindFirstChild("ClassicSword") then
    player.Character.ClassicSword.Parent = player.Backpack
end

player.Character:MoveTo(AttackCameraPart.Position + Vector3.new(0, 3, 0))
print("Player moved.")

Implement these changes and observe if the player can move as expected after the camera change. If the issue persists, the script might need further investigation to identify any specific causes of the movement restriction.

is this ai :skull:

you can see in the code that the changecamera remote event uses a string, not the actual object.
i already said it was specifically the line of code that fires the remot event that stops movement, not any animations. and what are print statements going to do??? the code runs just fine??? :sob:

its just to make sure it works bruh