How to make player stop moving when changing camera

I am making a shop thing were you go into a circle and it sends your camera to the shop, but when the camera gets sent there the character continues to move the direction it was heading, so I made the walkspeed 0, but that didnt help, because when I put the camera back on the character it just keeps going in the direction I was going in.

Video

Local Script

local player = game.Players.LocalPlayer

local playerGui = player:WaitForChild("PlayerGui")

local cam = workspace.CurrentCamera

local mouse = player:GetMouse()

local debounce = false

game.ReplicatedStorage.Events.CameraEvent.OnClientEvent:Connect(function()
	cam.CameraType = Enum.CameraType.Scriptable
	cam.CFrame = workspace.ShopBackground.CamPositions.CamPosition1.CFrame
	playerGui.ShopGui.Enabled = true
end)

playerGui:WaitForChild("ShopGui").CloseShop.MouseButton1Click:Connect(function()
	if playerGui.ShopGui.Enabled == true then
		cam.CameraType = Enum.CameraType.Custom
		playerGui.ShopGui.Enabled = false
		game.ReplicatedStorage.Events.CloseShopEvent:FireServer()
	end
end)

Server Script

script.Parent.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		local player = game.Players:GetPlayerFromCharacter(hit.Parent)
		game.ReplicatedStorage.Events.CameraEvent:FireClient(player)
		player.DevComputerMovementMode = Enum.DevComputerMovementMode.Scriptable
		player.DevTouchMovementMode = Enum.DevTouchMovementMode.Scriptable
		hit.Parent:FindFirstChild("Humanoid").WalkSpeed = 0
		hit.Parent.HumanoidRootPart.Position = script.Parent.PlayerPosition.Position
	end
end)

game.ReplicatedStorage.Events.CloseShopEvent.OnServerEvent:Connect(function(player)
	player.character.Humanoid.WalkSpeed = 16
end)
1 Like

Are you setting the MovementModes back to what they were before you changed them?